1.0.1 • Published 7 years ago

express-async-error-handler v1.0.1

Weekly downloads
33
License
ISC
Repository
-
Last release
7 years ago

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)
})