Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brunocarvalhodearaujo/error-handler
A error handler for express APIs applications.
https://github.com/brunocarvalhodearaujo/error-handler
Last synced: 9 days ago
JSON representation
A error handler for express APIs applications.
- Host: GitHub
- URL: https://github.com/brunocarvalhodearaujo/error-handler
- Owner: brunocarvalhodearaujo
- Created: 2018-09-23T22:09:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-02T22:51:10.000Z (about 1 year ago)
- Last Synced: 2023-11-02T23:27:58.002Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 776 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
error-handler
=============A error handler for express APIs applications.
## Installation
```sh
$ npm install --save @brunocarvalho/error-handler
```## usage
```ts
import express from 'express'
import errorHandler, { type RequestError } from '@brunocarvalho/error-handler'const app = express()
app.get('/', (req, res) => {
const err: RequestError = new Error('Not Found')
err.reason = `item not found in database`
err.statusCode = 404
throw err
})app.use(errorHandler())
```