assumeWontThrow

fnT assumeWontThrow(T)(lazy T expr, string msg = null, string file = __FILE__, size_t line = __LINE__) nothrow

Wraps a possibly-throwing expression in a nothrow wrapper so that it can be called by a nothrow function.

This wrapper function documents commitment on the part of the caller that the appropriate steps have been taken to avoid whatever conditions may trigger an exception during the evaluation of expr. If it turns out that the expression does throw at runtime, the wrapper will throw an AssertError.

(Note that Throwable objects such as AssertError that do not subclass Exception may be thrown even from nothrow functions, since they are considered to be serious runtime problems that cannot be recovered from.)

Parameters

exprThe expression asserted not to throw.
msgThe message to include in the AssertError if the assumption turns out to be false.
fileThe source file name of the caller.
lineThe line number of the caller.

Returns

The value of expr, if any.