1.0.0 • Published 7 years ago
with-error-handler v1.0.0
with-error-handler
Remove error handling boilerplate from node callbacks.
Installation
yarn install with-error-handlerUsage
fs.readdir(__dirname, (error, files) => {
if (error) throw error
// ...
})Becomes:
const weh = require('with-error-handler')
fs.readdir(__dirname, weh(files => {
// ...
}))This will throw the error by default. It is also possible to pass an error handler instead:
fs.readdir(__dirname, weh(files => {
// ...
}, console.error))When passing false as the second argument, the error will be silently ignored:
fs.readdir(__dirname, weh(files => {
// ...
}, false))License
MIT
1.0.0
7 years ago