https://github.com/eldimious/express-error-handler
https://github.com/eldimious/express-error-handler
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eldimious/express-error-handler
- Owner: eldimious
- License: apache-2.0
- Created: 2022-02-08T16:09:04.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T15:26:20.000Z (over 4 years ago)
- Last Synced: 2025-03-30T03:01:32.609Z (over 1 year ago)
- Language: TypeScript
- Size: 86.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome to @dimosbotsaris/express-error-handler 👋
> Simple Express.js middleware middleware to handle errors for APIs and return correct status, error message and trace.
## Install
```sh
npm install --save @dimosbotsaris/express-error-handler
```
## Usage
```sh
import { errorHandler } from '@dimosbotsaris/express-error-handler';
app.get('/bar', (req: Request, res: Response, next: NextFunction) => {
const error = new Error('Validation Error');
error.status = 400;
next(error);
});
app.use(errorHandler({}));
```
## Options
| Option | Type | Default | Description |
| ------ |------|---------| ------------ |
| trace| Boolean | `false` | If `true` the trace is attached to output. |
## Run tests
```sh
npm run test
```
## Author
👤 **Dimos Botsaris**
* Website: https://www.eldimious.com
* Twitter: [@el_dimious](https://twitter.com/el_dimious)
* Github: [@eldimious](https://github.com/eldimious)
* LinkedIn: [@dimosthenis-botsaris-5ab16485](https://www.linkedin.com/in/dimosthenis-botsaris-5ab16485/)
## Support Me
[](https://ko-fi.com/Y8Y797KCA)
## Show your support
Give a ⭐️ if this project helped you!