@onibi/errorhandler
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@onibi/errorhandler

Errorhandler middleware for express.js that catches and transforms HttpError's from the @onibi/errors library.


Usage example

import express from 'express';
import { Http404Error } from '@onibi/errors';
import handler from '@onibi/errorhandler';

let app = express();

app.get('/404', (req, res) => {
    throw new Http404Error();
})

// The errorHandler should always be the last thing added to the express app.
app.use(handler({
    // This should NEVER be true in a production env.
    includeStackTrace: true,  
    // Send a 404 response if there is no error to catch.
    // Set this to false if you want
    generate404: true
}));

app.listen(8080);

Readme

Keywords

Package Sidebar

Install

npm i @onibi/errorhandler

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

10.8 kB

Total Files

8

Last publish

Collaborators

  • matthijsr