boom
boom copied to clipboard
feat: allow boomifying any value (#291)
Creation of a new boomifyAny
that allows creating a boom error from an unknown
value.
This is a proposed fix for https://github.com/hapijs/boom/issues/291
Please tell me if you are ready to accept before I implement the tests.
For context, here is how this would be used:
try {
// some code that throw using non-error
} catch (err) {
// in TypeScript err is of type unknown
throw boomifyAny(err, { message: 'Unexpected error while performing code that throws non-error' })
}
Personally, I would much prefer to do a breaking change to boomify
, as suggested in https://github.com/hapijs/boom/issues/291#issuecomment-997863811, which would also update the argument type to any
.
Edit moved comment to https://github.com/hapijs/boom/issues/291#issuecomment-1119474178