0.2.0 • Published 5 years ago

mali-onerror v0.2.0

Weekly downloads
119
License
Apache-2.0
Repository
github
Last release
5 years ago

mali-onerror

Mali on error middleware. Calls function with error and context. The called function does not have access to control flow.

npm version build status Greenkeeper badge

API

mali-onerror ⇒ function

Mali on error middleware. Calls function with error and context. The called function does not have access to control flow.

Returns: function - the middleware function

ParamTypeDescription
fnfunctionThe function to call when an error occurs. Function has to have signature with signature (err, ctx)

Example

const onError = require('mali-onerror')

function errorLogger (err, ctx) {
  console.log('Error on %s: %s', ctx.name, err.toString())
}

app.use(onError(errorLogger))

License

Apache-2.0