Socket
Socket
Sign inDemoInstall

errorhandler

Package Overview
Dependencies
5
Maintainers
6
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    errorhandler

Development-only error handler middleware


Version published
Maintainers
6
Install size
195 kB
Created

Package description

What is errorhandler?

The errorhandler npm package is an error handler middleware for use with Express.js applications. It provides full stack traces and error message responses for errors during development, and a minimal response not leaking internal information in production.

What are errorhandler's main functionalities?

Development Error Handling

In a development environment, errorhandler can provide detailed stack traces and error messages to the console and the client, helping developers debug issues.

app.use(errorhandler({ log: errorNotification }))

function errorNotification(err, str, req) {
  var title = 'Error in ' + req.method + ' ' + req.url;
  console.error(title, str);
}

Production Error Handling

In a production environment, errorhandler can be used to send a generic error message to the client, without leaking sensitive stack trace information.

if (process.env.NODE_ENV === 'production') {
  app.use(errorhandler());
}

Other packages similar to errorhandler

Readme

Source

errorhandler

NPM Version NPM Downloads Build Status Test Coverage Gratipay

Development-only error handler middleware

Install

$ npm install errorhandler

API

var errorhandler = require('errorhandler')

errorhandler()

Create new middleware to handle errors and respond with content negotiation. This middleware is only intended to be used in a development environment, as the full error stack traces will be sent back to the client when an error occurs.

Example

var connect = require('connect')
var errorhandler = require('errorhandler')

var app = connect()

if (process.env.NODE_ENV === 'development') {
  // only use in development
  app.use(errorhandler())
}

License

MIT

FAQs

Last updated on 03 Sep 2014

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc