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