1.1.1 • Published 3 years ago

express-async-await-errors v1.1.1

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

Express Async Await Errors

Make Express.js handle async errors graciously.

Installation

npm install express-async-await-errors --save

Usage

'use strict'

const express = require('express')
const app = express()

const { catchAsyncErrorsOnRouter } = require('express-async-await-errors')
catchAsyncErrorsOnRouter(app) // you can also pass an express.Router() instead of the app

app.get('/', async (req, res) => {
  throw new Error("I'm an asynchronous error being caught!")
})

app.use(function(err, req, res, next) {
  res.status(500).send(`
    <h1>Server Error</h1>
    <pre>${err.stack}</pre>
  `)
})

app.listen(3000, () => console.log(`Example app listening on port 3000!`))
1.1.1

3 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago