@p-j/eapi-middleware-errorhandler
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

@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-errorhandler

API

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.

  • enableDebug enable the usage of ?debug=true to get the stack trace to appear in the response instead of an empty HTTP 500 response.
  • forwardError you may want to log exceptions with an external service, you can do so by providing a function here.

Package Sidebar

Install

npm i @p-j/eapi-middleware-errorhandler

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

17.9 kB

Total Files

13

Last publish

Collaborators

  • jparker