Function std.exception.ifThrown
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.
						
				CommonType!(T1,T2) ifThrown(E, T1, T2)
				(
				
				  scope lazy T1 expression,
				
				  scope lazy T2 errorHandler
				
				);
				
				
				CommonType!(T1,T2) ifThrown(E, T1, T2)
				(
				
				  scope lazy T1 expression,
				
				  scope T2 delegate(E) errorHandler
				
				);
				
				
				CommonType!(T1,T2) ifThrown(T1, T2)
				(
				
				  scope lazy T1 expression,
				
				  scope T2 delegate(Exception) errorHandler
				
				);
						
					
				Parameters
| Name | Description | 
|---|---|
| E | The type of Throwables to catch. Defaults toException | 
| 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 errorHandler.
Example
Revert to a default value upon an error:
import stdExample
Chain multiple calls to ifThrown, each capturing errors from the entire preceding expression.
import stdExample
The expression and the errorHandler must have a common type they can both be implicitly casted to, and that type will be the type of the compound expression.
// null and new Object have a common type(Object).
static assert(is(typeof(nullExample
Use a lambda to get the thrown object.
import std