express-async-error-handler
v1.0.1
Published
I'm not sure why this doesn't exist already. Handles a
Downloads
2
Maintainers
Readme
express-async-error-handler
I'm not sure why this doesn't exist already. Handles a
Usage
const asyncErrorHandler = require('express-async-error-handler')
const express = require('express')
const router = express.Router()
// Route
router.post('/hello', asyncErrorHandler(async function() {
await thisWillThrowAnError()
}))
// Error handler
router.use(function(err, req, res, next) {
res.status(err.status || 500)
})