Skip to content

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

Notifications You must be signed in to change notification settings

vitta-health/dev-error-handler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 53.1%
  • CSS 36.2%
  • HTML 10.7%