try_catch
v1.0.2
Published
try/catch as a function.
Maintainers
Readme
try_catch
try/catch as a function.
The lame way:
var x
try {
x = thisMightThrow()
} catch (err) {
x = somethingElse()
}With try_catch:
const tryCatch = require('try_catch')
const x = tryCatch(thisMightThrow, somethingElse)install
npm install try_catchAPI
tryCatch(tryFn, catchFn)
tryFn: functioncatchFn: function- returns: the value returned by
tryFn()unlesstryFn()throws, in which case it will be the value returned bycatchFn().
