1.0.2 • Published 7 years ago

try_catch v1.0.2

Weekly downloads
51
License
CC0-1.0
Repository
github
Last release
7 years ago

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() unless tryFn() throws, in which case it will be the value returned by catchFn().