Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/last-error-middleware
Middleware for catching the last error in your express.js apps
https://github.com/segment-boneyard/last-error-middleware
Last synced: about 7 hours ago
JSON representation
Middleware for catching the last error in your express.js apps
- Host: GitHub
- URL: https://github.com/segment-boneyard/last-error-middleware
- Owner: segment-boneyard
- Created: 2013-10-18T18:39:20.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-05T23:24:00.000Z (almost 11 years ago)
- Last Synced: 2024-10-13T17:38:29.174Z (about 1 month ago)
- Language: JavaScript
- Size: 242 KB
- Stars: 6
- Watchers: 39
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# last-error-middleware
Middleware for catching the last `express.js` error and rendering it as json or an error page.
## Installation
$ npm install last-error-middleware
## Example
```js
var lastError = require('last-error-middleware');app.use(lastError({ pages: {
'401': 'path/to/401.html',
'404': 'path/to/404.html',
'500': 'path/to/500.html',
'503': 'path/to/503.html',
'*' : 'path/to/omg.html',
}));
```## API
### .LastError(options)
Construct a `last-error` middleware generator with custom `options`. The defaults are:```js
{
"pages": {}, // status code to html template path
"stack": false // return the error stack with json responses
}
```### on('err', ..)
Emitted on every error.
```js
var lastError = require('last-error-middleware');var errors = lastError({ pages: {
'401': 'path/to/401.html',
'404': 'path/to/404.html',
'500': 'path/to/500.html',
'503': 'path/to/503.html'
});app.use(errors);
errors.on('err', function (err) {
console.log(err.stack);
});
```## License
```
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
```