import core.exception : AssertError; //import std.exception : assertThrown, assertNotThrown; bool func() { throw new Exception("e"); } auto e = assertThrown!AssertError(ensure(func())); assert(e.line == __LINE__ - 1); auto e2 = assertThrown!AssertError(ensure(false)); assert(e2.line == __LINE__ - 1); bool b = assertNotThrown!AssertError(ensure(true)); assert(b);