co-try-catch
Provides a nicer way to handle errors avoiding ugly native try {} catch (e) {}
indentation.
Example
const tryCatch = ; { const response = ; if response /* handle error */ return /* and stop function execution */; /* continue with the normal function execution */ console;}
...also, if you prefer...
const err result = ;
Api
*tryCatch(gen: Function|Function*|Promise): TryCatchResult
TryCatchResult
isError(): Boolean
Returns if function has thrown an error
isSuccess(): Boolean
Returns if function didn't throw an error
failed(): Boolean
alias of isError()
succeeded(): Boolean
alias of isSuccess()
getError(): Mixed
Returns the thrown object
getResult(): Mixed
Returns result of the function execution
Supports nested calls
if a function call returns an instance of TryCatchResult
it is passed up to the caller
const tryCatch = ; ;