6.0.0 • Published 3 months ago

express-json-error-handler v6.0.0

Weekly downloads
378
License
MIT
Repository
github
Last release
3 months ago

express-json-error-handler

Error handler for express JSON APIs

Install

$ npm install express-json-error-handler

Usage

Example

import express from 'express';
import jsonErrorHandler from 'express-json-error-handler';

const app = express();

app.use(jsonErrorHandler());

Options

The jsonErrorHandler function takes an option options object that may contain any of the following keys:

log

The log option, if supplied, is called as log({err, req, res}) when server errors occur.

Example

import express from 'express';
import jsonErrorHandler from 'express-json-error-handler';

const app = express();

app.use(jsonErrorHandler({
  log({err, req, res}) {
    console.log(err); // The original error object
    console.log(req); // The request object
    console.log(res); // The response object
  }
}));

License

MIT

6.0.0

3 months ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.1.0

2 years ago

4.0.0

4 years ago

3.1.0

4 years ago

3.0.0

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.0

8 years ago