try_catch
v1.0.2
Published
try/catch as a function.
Downloads
28
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_catch
API
tryCatch(tryFn, catchFn)
tryFn: function
catchFn: function
- returns: the value returned by
tryFn()
unlesstryFn()
throws, in which case it will be the value returned bycatchFn()
.