1 /** 2 * Pijamas, a BDD assertion library for D. 3 * 4 * License: Licensed under the MIT license. See LICENSE for more information. 5 */ 6 module pijamas.exception; 7 8 version (MirNoGCException) { 9 import mir.exception : MirException; 10 11 alias BaseException = MirException; 12 13 } else { 14 static if (__traits(compiles, { import unit_threaded.should : UnitTestException; })) { 15 import unit_threaded.should : UnitTestException; 16 17 alias BaseException = UnitTestException; 18 19 } else static if (__traits(compiles, { import dunit.error : DUnitAssertError; })) { 20 import dunit.error : DUnitAssertError; 21 22 alias BaseException = DUnitAssertError; 23 24 } else { 25 26 alias BaseException = Exception; 27 } 28 } 29 30 /** 31 * An exception thrown when a test fails 32 */ 33 public class AssertException : BaseException { 34 35 version (MirNoGCException) { 36 37 /** 38 * Constructor 39 * 40 * Params: 41 * msg = The failure message 42 * file = The filename where the test failed 43 * line = The line where the test failed 44 */ 45 @nogc @safe pure nothrow this(scope const(char)[] msg, string file = __FILE__, size_t line = __LINE__) { 46 super(msg, file, line); 47 } 48 49 /// ditto 50 @nogc @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__) { 51 super(msg, file, line); 52 } 53 54 } else { 55 /** 56 * Constructor 57 * 58 * Params: 59 * msg = The failure message 60 * file = The filename where the test failed 61 * line = The line where the test failed 62 */ 63 this(string msg, string file = __FILE__, size_t line = __LINE__) @safe pure { 64 super(msg, file, line); 65 } 66 } 67 }