You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Is your feature request related to a problem? Please describe it
#9705 added some support for error causes but it does not allow you to provide a custom message along with a cause (the PR description points this out).
Describe the solution you'd like
I'd like there to be a 3rd parameter added to HttpException that mirrors the options object in Node as of 16.9.0: https://nodejs.org/docs/latest-v16.x/api/errors.html#new-errormessage-options and an additional parameter for the other exceptions, this way we can pass in a custom message like normal while specifying a cause.
Many (or all) of the exceptions have an optional second string parameter for the description so in order to allow that to be optional while specifying the options object, it can be distinguished by whether or not a string is passed for the second option, if it is an object then we know it's the options object and not a description and the default should be used.
It should be backwards compatible and the fact that it is the same as the default from Node now means that it should be easy to understand for developers.
What is the motivation / use case for changing the behavior?
We often handle an error and want to add a new message to it without losing the information from the original error. The current implementation lets us add an error as the cause but it needs to be the first parameter which means we cannot add any custom information there. With this change we can have the best of both worlds and make full use of error causes/chaining along with the rest of the functionality that NestJS exceptions provide.
The text was updated successfully, but these errors were encountered:
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
#9705 added some support for error causes but it does not allow you to provide a custom message along with a cause (the PR description points this out).
Describe the solution you'd like
I'd like there to be a 3rd parameter added to HttpException that mirrors the options object in Node as of 16.9.0: https://nodejs.org/docs/latest-v16.x/api/errors.html#new-errormessage-options and an additional parameter for the other exceptions, this way we can pass in a custom message like normal while specifying a cause.
Many (or all) of the exceptions have an optional second string parameter for the description so in order to allow that to be optional while specifying the options object, it can be distinguished by whether or not a string is passed for the second option, if it is an object then we know it's the options object and not a description and the default should be used.
Teachability, documentation, adoption, migration strategy
It should be backwards compatible and the fact that it is the same as the default from Node now means that it should be easy to understand for developers.
What is the motivation / use case for changing the behavior?
We often handle an error and want to add a new message to it without losing the information from the original error. The current implementation lets us add an error as the cause but it needs to be the first parameter which means we cannot add any custom information there. With this change we can have the best of both worlds and make full use of error causes/chaining along with the rest of the functionality that NestJS exceptions provide.
The text was updated successfully, but these errors were encountered: