cc-error-handler

0.0.4 • Public • Published

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())

Readme

Keywords

none

Package Sidebar

Install

npm i cc-error-handler

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • oleiba