called delegate
if true when catch exception with type != E throw it out, if false ignore it
true if is catched exception of type E, false otherwise
assert( mustExcept!Exception( { throw new Exception("test"); } ) ); assert( !mustExcept!Exception( { throw new Throwable("test"); }, false ) ); assert( mustExcept( { throw new Exception("test"); } ) ); assert( !mustExcept( { throw new Throwable("test"); }, false ) ); assert( mustExcept!Throwable( { throw new Exception("test"); } ) ); assert( mustExcept!Throwable( { throw new Throwable("test"); } ) ); assert( !mustExcept!Exception({ auto a = 4; }) );
static class A {} static assert( !__traits(compiles, mustExcept!A({})) ); static class TestExceptionA : Exception { this() @safe pure nothrow { super( "" ); } } static class TestExceptionB : Exception { this() @safe pure nothrow { super( "" ); } } static class TestExceptionC : TestExceptionA { this() @safe pure nothrow { super(); } } assert( mustExcept!Exception({ throw new TestExceptionA; }) ); assert( mustExcept!Exception({ throw new TestExceptionB; }) ); assert( mustExcept!TestExceptionA({ throw new TestExceptionA; }) ); assert( mustExcept!TestExceptionA({ throw new TestExceptionC; }) ); assert( mustExcept!TestExceptionB({ throw new TestExceptionB; }) ); assert( !mustExcept!TestExceptionB( { throw new TestExceptionA; }, false ) ); assert( !mustExcept!TestExceptionA( { throw new TestExceptionB; }, false ) ); auto test_b_catched = false; try mustExcept!TestExceptionA({ throw new TestExceptionB; }); catch( TestExceptionB ) test_b_catched = true; assert( test_b_catched );
try call delegate