api-error-handler

Express error handlers for JSON APIs

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
api-error-handler
96131.0.08 years ago8 years agoMinified + gzip package size for api-error-handler in KB

Readme

api-error-handler
!NPM versionnpm-imagenpm-url !Build statustravis-imagetravis-url !Test coveragecoveralls-imagecoveralls-url !Dependency Statusdavid-imagedavid-url !Licenselicense-imagelicense-url !Downloadsdownloads-imagedownloads-url !Gittipgittip-imagegittip-url
An error handler for JSON APIs, meant to be used with http-errors-style errors.

Example

var errorHandler = require('api-error-handler');

var api = new express.Router();
api.get('/users/:userid', function (req, res, next) {

});

api.use(errorHandler());

app.use('/api', api);

API

.use(errorHandler(options))

Currently no options.

Errors

4xx errors are exposed to the client. Properties exposed are:
  • message
  • type
  • name
  • code
  • status

5xx errors are not exposed to the client. Instead, they are given a generic message as well as the type.