Boom

How often do we visit the list of HTTP status code to check or to inform the user about the status of the request? Well you might remember most of them, but would it not be cool to have more humanized mechanism to handle this?

Well here is BOOM HTTP-friendly error objects, as the name suggest it's make the error reporting more friendly.

Installing it is like any other node module: npm install boom

It provides the below error messages:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[
  'badRequest',
  'unauthorized',
  'forbidden',
  'notFound',
  'methodNotAllowed',
  'notAcceptable',
  'proxyAuthRequired',
  'clientTimeout',
  'conflict',
  'resourceGone',
  'lengthRequired',
  'preconditionFailed',
  'entityTooLarge',
  'uriTooLong',
  'unsupportedMediaType',
  'rangeNotSatisfiable',
  'expectationFailed',
  'internal',
  'notImplemented',
  'badGateway',
  'serverTimeout',
  'gatewayTimeout',
  'badImplementation'
 ]

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
> var boom = require('boom');

> var notFound = boom.notFound("Sorry, it's not here :(")

> notFound

{ [Error: Sorry, it's not here :(]
  data: null,
  isBoom: true,
  output: 
   { statusCode: 404,
     payload: 
      { statusCode: 404,
        error: 'Not Found',
        message: 'Sorry, it\'s not here :(' },
     headers: {} },
  reformat: [Function] }

> notFound.output.payload

{ statusCode: 404,
  error: 'Not Found',
  message: 'Sorry, it\'s not here :(' }

GIF FTW

Thanks to @WalmartLabs team for this module, specially for the maintainers Eran Hammer and Wyatt Preul

Suggest a module

Comments