boom icon indicating copy to clipboard operation
boom copied to clipboard

feat: allow boomifying any value (#291)

Open matthieusieben opened this issue 2 years ago • 3 comments

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

matthieusieben avatar Dec 21 '21 12:12 matthieusieben

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' })
}

matthieusieben avatar May 06 '22 09:05 matthieusieben

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.

kanongil avatar May 06 '22 10:05 kanongil

Edit moved comment to https://github.com/hapijs/boom/issues/291#issuecomment-1119474178

matthieusieben avatar May 06 '22 10:05 matthieusieben