Socket
Socket
Sign inDemoInstall

dev-error-handler

Package Overview
Dependencies
65
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dev-error-handler

HTTP error-handling middleware that displays syntax highlighted source code.


Version published
Weekly downloads
11
increased by266.67%
Maintainers
1
Install size
4.56 MB
Created
Weekly downloads
 

Readme

Source

dev-error-handler

HTTP error-handling middleware that displays syntax highlighted source code. To be used in development only!

Build Status

pic

usage

You can use it with Node's http module:

var errorHandler = require('dev-error-handler');

http.createServer(function(req, res) {
  if (req.url === '/favicon.ico') { return res.end(); }

  try {
    getSampleError();
  }
  catch(err) {
    errorHandler(err, req, res);
  }
}).listen(7777);

..or most likely with something like Express:

var errorHandler = require('dev-error-handler');
var express = require('express');
var app = express();
var ENV = process.env.NODE_ENV || 'development';

app.get('*', function(req, res, next) {
  return next(new Error('oh noess!'));
});

if (ENV === 'development') {
  app.use(errorHandler);
}

app.listen(process.env.PORT || 7777);

Type npm run example to hit if off!

test

npm test

similar modules

license

MIT

Keywords

FAQs

Last updated on 07 Jan 2016

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