handle-try-catch
v0.1.2
Published
Module wrapping async handler function with try catch
Downloads
23
Maintainers
Readme
Install
npm install handle-try-catch --saveExample
const wrap = require('handle-try-catch')
router.get('/', wrap(async (req, res, next) => {
...do somthing
// next()
res.status(200).send('success!')
}))
router.get('/', wrap(async (req, res, next) => {
...do somthing
throw new Error()
}))
router.use((err, req, res, next) => {
... do error handling
})