hapi icon indicating copy to clipboard operation
hapi copied to clipboard

output validation error pass source along

Open catalint opened this issue 10 years ago • 5 comments

When request response validation fails , when creating the Boom object, also pass along the original error object ?

https://github.com/hapijs/hapi/blob/master/lib/validation.js#L201 right now it's

return next(Boom.badImplementation(err.message));

what do you say about

return next(Boom.badImplementation(err.message, err));

or

return next(Boom.badImplementation(err.message, value));

Use case :

I'm trying to log these errors in sentry and I'm only getting the message that it failed validation at some key, if I add the err or value in data, I can see the context and debug faster.

What are your thoughts on this ? I would do a PR if you are ok.

catalint avatar Jun 07 '16 07:06 catalint

Why not do next(Boom.badImplementation(err)) and you can log/parse/send to sentry whatever you want on server.on('response', ...)

AdriVanHoudt avatar Jun 07 '16 11:06 AdriVanHoudt

the way Boom is designed, it wants a message in the first param, not an error object , the second param is reserved for extra data

catalint avatar Jun 07 '16 11:06 catalint

ah yes sorry missed that, you can still handle the error on server.on('response', ...) no?

AdriVanHoudt avatar Jun 07 '16 16:06 AdriVanHoudt

Use the new failAction feature with a function.

hueniverse avatar Aug 23 '16 07:08 hueniverse

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.

lock[bot] avatar Jan 09 '20 07:01 lock[bot]