1.1.1 • Published 4 years ago
@p-j/eapi-middleware-errorhandler v1.1.1
@p-j/eapi-middleware-errorhandler
A middleware to handle exceptions within your handler & middleware stack. It can be configured to log the error to an external service or to render the Error to the response.
Installation
- From the NPM registry
npm install @p-j/eapi-middleware-errorhandler
# or
yarn add @p-j/eapi-middleware-errorhandlerAPI
withErrorHandler is a Middleware Factory; it takes the following options:
export interface WithErrorHandlerOptions {
enableDebug?: boolean
forwardError?: ErrorForwarder
}As noted above, none of the options are required.
enableDebugenable the usage of?debug=trueto get the stack trace to appear in the response instead of an empty HTTP 500 response.forwardErroryou may want to log exceptions with an external service, you can do so by providing a function here.