-
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
Allow decorating a boom error #160
Comments
The error message is pretty self explanatory: "Cannot provide statusCode or message with boom error" |
I am sorry but I don't see how this behavior is consistent with the documentation, especially since the behavior changed and the documentation did not. If I can only get my original Boom object back when I don't specify a In my opinion, this new behavior makes the |
This was always how |
I am not expecting the Boom error to be over-written, I am expecting it get returned unchanged. But I want non-Boom errors to be wrapped. Again, that's only useful when some other function returns an error that can or can not be a Boom object. const nonConsistentFunction = function(input, callback) {
if (input === 'a') {
return callback(new Error('an error'));
}
else {
return callback(Boom.badData());
}
}
nonConsistentFunction(value, (error, result) => {
if (error) {
return reply(Boom.wrap(error, 500, 'terrible error'));
}
// something else
} In the past:
Now:
What breaks the previous behavior is this commit: 544cc13db7c7fc99b43bbb8eb1ce2ce57f2c78db |
Past being what version? |
As far as I can tell, the last working version was |
@mariecl Would you happen to be working on a fix? Seems like it's a simple solution, the author of that commit should of used double bangs in order to coerce those values into Booleans like so... Hoek.assert(!error.isBoom || (!!statusCode && !!message), 'Cannot provide statusCode or message with boom error'); |
@mariecl @samueljoli If you happen not to have time to create the PR, I'll be happy to help. |
I had not understood that @hueniverse was willing to take a PR on this but happy to work on something today just in case. |
Done ✅ |
I wasn't looking for a PR just yet... (I was on vacation). There is no obvious right answer here other than another breaking change to clear this up or a secondary interface for your use case. I just need to pick one. I'll figure it out later today. Simply ignoring the arguments is a non-starter. It was a bug that has some useful side effects for you. |
No worries. Thanks for considering this as a potential future enhancement and thanks for the good work! |
@mariecl I'm sure you've already come up with a work around for your application. If you have a single common entry point into your application did you decide to mutate / monkeypatch Boom with something like |
We should definitely put in a PR to fix the docs though, you want to do this @mariecl ? Otherwise I'm happy to. |
@AJamesPhillips I think the documentation was already updated with the new solution the maintainer came up with. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
What are you trying to achieve or the steps to reproduce?
I am trying to wrap a Boom object (whether it was an error that got wrapped before, or an error created with Boom).
or
What was the result you received?
In both cases:
What did you expect?
I expected no thrown error and Boom.wrap to return the original Boom object, as stated in the README:
Context
The text was updated successfully, but these errors were encountered: