express-async-error-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

express-async-error-wrapper

npm version

A stupid wrapper for express routes to catch and call next() on any errors thrown, allowing you to use to throw errors while in async functions or promises.

Example Usage

const app = require('express')();
const wrap = require('express-async-error-wrapper');
 
// Will catch the error and go through the express error handler.
app.use('/with', wrap(async () => {
    throw new Error('Oh noes.')
}));
 
// Will crash the server and cause timeout in the client.
app.use('/without', async () => {
    throw new Error('Oh noes.')
});
 
console.log('Starting server on port 8000')
app.listen(8000);

Readme

Keywords

none

Package Sidebar

Install

npm i express-async-error-wrapper

Weekly Downloads

31

Version

1.0.4

License

MIT

Unpacked Size

2.99 kB

Total Files

6

Last publish

Collaborators

  • tethik