-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for native cause
#300
Comments
I think that's a great idea. If we can limit the blast radius by keeping |
I would definitely like to see I'm not especially a fan of the new proposed syntax, which will require you to pass a Ideally it should look like a regular This will obviously be a breaking change. However, the change is limited, as it will only affect boom object creators that use helper methods with the Btw. on supported node releases, you should already be able to do something like: throw badImplementation(new Error('Stuff should not throw an error', { cause: err })); |
I personally rely quite a lot on helpers and the optional Additionally, changing the helper's second argument to behave like the constructor's What should happen with unauthorized(message, scheme, attributes) |
Should all helpers have the following signature? type helper<T = any> = (message: string, options: Options<T>) => Boom<T> Which means that the 3 helpers that do not currently have only export function unauthorized<Data>(message: string, options: Options<Data> & { scheme?: string; attributes?: string | unauthorized.Attributes }) => Boom<Data>
export function methodNotAllowed<Data>(message: string, options: Options<Data> & { allow?: allow?: string | string[] }) => Boom<Data>
export function internal<Data>(message, options: Options<Data>) |
Your suggestion seems very sensible (except that all args should be optional): type HelperMethod<T = any> = (messageOrError?: string | Error, options?: Options<T>) => Boom<T>; For |
Do we plan to have this soon? If we agree on an implementation I'd be happy to help writing the PR |
Support plan
Context
What problem are you trying to solve?
Errors now have a
cause
property described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/causeWe should be able to easily set the cause when creating a Boom error.
Currently, the following must be done:
Do you have a new or modified API suggestion to solve the problem?
It is my understanding that currently, in the Hapi ecosystem, the
data
property of Boom errors is sometimes used to contain the original error, so anything proposed here will likely largely impact the Hapi ecosystem.in order not to break the current api too much, we could just add a new option on error creators:
and specify that from now on,
data
should no longer be used to contain the originating error.The text was updated successfully, but these errors were encountered: