ifThrown

fnCommonType!(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

EThe type of Throwables to catch. Defaults to Exception
T1The type of the expression.
T2The return type of the error handler.
expressionThe expression to run and return its result.
errorHandlerThe handler to run if the expression throwed.

Returns

expression, if it does not throw. Otherwise, returns the result of

errorHandler.

fnCommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, scope T2 delegate(E) errorHandler)

ditto

fnCommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate(Exception) errorHandler)

ditto