derby-error

1.0.1 • Public • Published

Derby Error

Derby JS middleware that adds default error handling redirects.

For example:

http://site.com/unknown/path => http://site.com/error/404

Why should I use this?

It allows your client app to handle errors the same way you'd handle normal page requests. Simply add a route for /error/:code. Now there's no need to create a static app to handle errors. Of course, you can still do that if you'd like.

Installation

$ npm install derby-error --save

In your server file:

var error = require('derby-error');

expressApp
  // ...
  // ...
  // place after all other middleware
  .use(error());

Usage

Create an error handling route:

// assumes you have views such as: 404.html, 500.html, etc.
app.get('/error/:code', function (page, model, params) {
  page.render(params.code);
});

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i derby-error

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • psirenny