Express error handlers for JSON APIs
Clone or download
Latest commit df765a5 Dec 10, 2014
Type Name Latest commit message Commit time
Failed to load latest commit information.
test creation Dec 10, 2014
.gitignore creation Dec 10, 2014
.travis.yml creation Dec 10, 2014
LICENSE creation Dec 10, 2014 creation Dec 10, 2014
index.js return stack traces when not in production Dec 10, 2014
package.json 1.0.0 Dec 10, 2014


NPM version Build status Test coverage Dependency Status License Downloads Gittip

An error handler for JSON APIs, meant to be used with http-errors-style errors.


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

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



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



Currently no options.


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.