New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-boombox

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-boombox

Boom error wrapper

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53
increased by341.67%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Hapi-BoomBox

Hapi plugin Boom wrapper

What

Boombox allows you to create Boom errors and errors from a given errors set. This can be used to have errors in your code that uses generic keys e.g. USER_NO_ACCESS and it will be translated to a Boom error with a decent message e.g. You have no access to this method. Boombox also allows you to specify the type of Boom error. e.g. USER_NO_ACCESS can be defined as a methodNotAllowed and it will automaticlly generate a Boom error with the right statuscode.

How

(server/reply).boom(Error key/Error/String/Object, [returnError], [convert])

You can pass anything into the boom method. Boombox will try to match an error from the errors file and otherwise generate another Boom error. You pass some options into the method. * returnError - If false will return only the error message. If convert is true Boombox will try to convert to an error first (matched from errors or general error) * convert - If false will not try to convert to a Boom error. If returnError is true will generate a generic Error If you try to convert a non existing key into a Boom error it will generate a Internal Server Error error. This is by design (atm) to make sure you notice it when you use an non implemented error key.

Test

100% test coverage! Also look in the tests for more examples.

Notes

Personally I use this in a Hapi server to use generic keys as errors in my code but to give the end user a decent error message and to easily match errors with the right error code. Just do reply.boom(err); for your errors and you are sure to pass a decent error to your user.

Keywords

FAQs

Package last updated on 12 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc