0.0.4 • Published 8 years ago

cc-error-handler v0.0.4

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

Build Status Coverage Status npm version

error-handler

Express.js error handling middleware.

Installation

$ npm install cc-error-handler

Running the tests

$ npm install
$ mocha

API

var errorhandler = require('cc-error-handler')

errorhandler(options)

Create new error handling middleware.

options

env

'development' will include stack trace, and will accumulate original errors initiated from third party or separate servers. Default is undefined.

log

One of two types: boolean - a boolean for determining whether the error handler should log the error messages. true will use console.error by default for logging. function - a function to process an error, invoked with err. Default is true.

Example

As with any express error handling middleware, it should be put after the router middleware:

var express = require('express')
var app = express()
var bodyParser = require('body-parser')
var errorHandler = require('cc-error-handler')

app.use(bodyParser())
app.get('/error', function (req, res, next) {
	next('Something went wrong')
})
app.use(errorHandler())