hapijs / boom

HTTP-friendly error objects
Other
2.94k stars 192 forks source link

Optional second param for Boom.isBoom() to verify status code #265

Closed dominykas closed 4 years ago

dominykas commented 4 years ago

Support plan

Context

What problem are you trying to solve?

When catching Boom errors and handling specific response codes, one has to check for:

Boom.isBoom(err) && err.output.statusCode === 404

This needs extra coverage for the && condition.

It would be handy to just be able to say Boom.isBoom(err, 404) or Boom.isBoom(err, { statusCode: 404 }).

Do you have a new or modified API suggestion to solve the problem?

See above.

Happy to PR.