Mali on error middleware. Calls function with error and context. The called function does not have access to control flow.
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
Param | Type | Description |
---|---|---|
fn | function |
The function to call when an error occurs. Function has to have signature with signature (err, ctx) |
Example
const onError = require('@malijs/onerror')
function errorLogger (err, ctx) {
console.log('Error on %s: %s', ctx.name, err.toString())
}
app.use(onError(errorLogger))
Apache-2.0