Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

erros

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erros

Simple express error handler

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
108
decreased by-0.92%
Maintainers
1
Weekly downloads
 
Created
Source

Erros.js

Simple Express error handler

Installation

npm install erros

Usage

var app = require('express')();
var erros = require('erros');

// configure your app...

app.use(erros.handler()); // should be last in the middleware stack

Responds to content types:

  • text/html
  • text/plain
  • application/json

Define your own view folder and view engine extension.

app.use(erros.handle({views: __dirname+'/views', view_ext: 'jade'}));
  • views your views directory, default ./
  • view_ext view engine extension, default jade

Accept: text/html will always attempt to respond with res.render.

Your error pages should be named 5xx.your-extension and 4xx.your-extension for Server and Client errors respectively.


Change the default Status code.

app.use(erros.handle({default_status: 200}));

Status code will be 200, unless your error has a status property defining another code. Eg. use of custom Error

function MyError(msg, status) {
  Error.captureStackTrace(this);
  this.message = msg;
  this.name = 'MyError';
  this.status = status;
}

MyError.prototype = Object.create(Error.prototype);

License

MIT

Keywords

FAQs

Package last updated on 02 May 2014

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc