Skip to content

malijs/onerror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e954889 · Mar 16, 2021

History

35 Commits
Mar 14, 2021
Dec 30, 2016
Dec 30, 2016
Jan 20, 2019
Dec 30, 2016
Jan 20, 2019
Mar 14, 2021
Mar 16, 2021
Mar 16, 2021
Mar 16, 2021
Mar 16, 2021
Jan 20, 2019

Repository files navigation

@malijs/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

API

@malijs/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

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

License

Apache-2.0