- Node >= 5.0.0, with
--es-staging
flag
var Try = require('try-promise'); // Try is a subclass of Promise
new Try(act, args).then(onfulfill, onreject);
-
act(...args)
would be executed -
onfulfill(result)
would be executed withresult = act(...args)
if no error was thrown -
onreject(error)
would be executed ifact(...args)
throwerror
var tryCatch = require('try-promise').try;
var promise = tryCatch(act, args).then(onfulfill, onreject);