Socket
Book a DemoInstallSign in
Socket

express-json-error-handler

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-json-error-handler

Error handler for express JSON APIs

6.1.0
latest
Source
npmnpm
Version published
Weekly downloads
212
12.17%
Maintainers
1
Weekly downloads
 
Created
Source

express-json-error-handler

Error handler for express JSON APIs

Install

$ npm install express-json-error-handler

Usage

Example

import express from 'express';
import {expressJsonErrorHandler} from 'express-json-error-handler';

const app = express();

app.use(expressJsonErrorHandler());

Options

The expressJsonErrorHandler 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 {expressJsonErrorHandler} from 'express-json-error-handler';

const app = express();

app.use(expressJsonErrorHandler({
  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

Keywords

express

FAQs

Package last updated on 16 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.