errorHandler.
ifThrown
fn
CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)(lazy scope T1 expression, lazy scope T2 errorHandler)ML-style functional exception handling. Runs the supplied expression and returns its result. If the expression throws a Throwable, runs the supplied error handler instead and return its result. The error handler's type must be the same as the expression's type.
Parameters
E | The type of Throwables to catch. Defaults to Exception |
T1 | The type of the expression. |
T2 | The return type of the error handler. |
expression | The expression to run and return its result. |
errorHandler | The handler to run if the expression throwed. |
Returns
expression, if it does not throw. Otherwise, returns the result of
fn
CommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, scope T2 delegate(E) errorHandler)ditto
fn
CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate(Exception) errorHandler)ditto