Package Exports
- escape-try-catch
- escape-try-catch/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escape-try-catch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Foobar
Escape-Try-Catch is an npm package that helps you in escaping the traditional try catch mechanism . You can freely write your code without thinking of error handling for your async calls
Installation
Use the npm package manager to install foobar.
npm install escape-try-catchUsage
const { asyncMiddleware } = require("escape-try-catch")
# Use it like this inside your routes
router.get('/test', asyncMiddleware(getUser))
# your controller function looks like this
getUser: async function(req,res) {
let users = User.find({})
res.send(users)
}
# Any error that occurs in the above function will be handled by the middleware
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.