node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »


Jungles Errors

Middleware for dealing with errors. The reason why this isn't an app you can mount is because apps can't catch errors from other apps (bug?). This also should be last in the Express stack so it can catch 404s.


require('jungles-errors')(/* your express app */, /* optional path to custom error view */);


var app = express();
require('jungles-errors')(app, __dirname + '/template.jade'); // template.jade string is optional. 

Throw errors

If the type is 'http' the correct response code is set.

next({ type: 'http', error: 404 });

If the type isn't 'http' a 500 Internal Server Error is shown.

next({ type: 'database', error: 'Connection problems' });