Report a bug
		
				If you spot a problem with this page, click here to create a GitHub issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	mir.exception
@nogc exceptions and errors definitions.
Most of the API Requires DIP1008.
- ref @trusted autoenforce(string fmt, string file = __FILE__, int line = __LINE__, Expr)(auto return ref scope Exprarg);
- Examples:import mir.exception; try enforce!"Msg"(false); catch(Exception e) assert(e.msg == "Msg"); 
- classMirException: object.Exception;
- Examples:Generic stylestatic if (__traits(compiles, (()@nogc {import mir.format;})())) { import mir.exception; try throw new MirException("Hi D", 2, "!"); catch(MirException e) assert(e.scopeMessage == "Hi D2!"); } Examples:Generic style, GC allocated MSGstatic if (__traits(compiles, (()@nogc {import mir.format;})())) { import mir.exception; try throw new MirException("Hi D", 2, "!"); catch(Exception e) assert(e.message == "Hi D2!"); } Examples:C++ stylestatic if (__traits(compiles, (()@nogc {import mir.format;})())) { import mir.exception; import mir.format; try throw new MirException(stringBuf() << "Hi D" << 2 << "!" << getData); catch(Exception e) assert(e.scopeMessage == "Hi D2!"); } Examples:Low-level stylestatic if (__traits(compiles, (()@nogc {import mir.format;})())) { import mir.exception; import mir.format; auto buffer = stringBuf(); try throw new MirException(buf.print( "Hi D", 2, "!").data); catch(Exception e) assert(e.msg == "Hi D2!"); } Examples:@safe pure nothrow @nogc bool func(scope const(char)[] msg) { /// scope messages are copied try throw new MirException(msg); catch(Exception e) assert(e.msg == msg); /// immutable strings are not copied static immutable char[] gmsg = "global msg"; try throw new MirException(gmsg); catch(Exception e) assert(e.msg is gmsg); return __ctfe; } assert(func("runtime-time check") == 0); static assert(func("compile-time check") == 1); - pure nothrow @nogc @trusted this(scope const(char)[]msg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @trusted this(scope const(char)[]msg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
 pure nothrow @nogc @safe this(stringmsg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @safe this(stringmsg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
- Parameters:const(char)[] msgmessage. No-scope msgis assumed to have the same lifetime as the throwable. scope strings are copied to internal buffer.string filefile name, zero terminated global string size_t lineline number Throwable nextInChainnext exception in the chain (optional) 
- pure this(Args...)(auto ref scope const Argsargs, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null)
 if (Args.length > 1 && !is(Args[$ - 1] == Throwable));
- Generic multiargument overload. Constructs a string using the print function.
 
- classMirError: object.Error;
- Examples:@system pure nothrow @nogc bool func(scope const(char)[] msg) { /// scope messages are copied try throw new MirException(msg); catch(Exception e) assert(e.msg == msg); /// immutable strings are not copied static immutable char[] gmsg = "global msg"; try throw new MirError(gmsg); catch(Error e) assert(e.msg is gmsg); return __ctfe; } assert(func("runtime-time check") == 0); static assert(func("compile-time check") == 1); - pure nothrow @nogc @trusted this(scope const(char)[]msg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @trusted this(scope const(char)[]msg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
 pure nothrow @nogc @safe this(stringmsg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @safe this(stringmsg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
- Parameters:const(char)[] msgmessage. No-scope msgis assumed to have the same lifetime as the throwable. scope strings are copied to internal buffer.string filefile name, zero terminated global string size_t lineline number Throwable nextInChainnext exception in the chain (optional) 
- pure this(Args...)(auto ref scope const Argsargs, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null)
 if (Args.length > 1 && !is(Args[$ - 1] == Throwable));
- Generic multiargument overload. Constructs a string using the print function.
 
- templateMirThrowableImpl()
- 
- pure nothrow @nogc @trusted this(scope const(char)[]msg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @trusted this(scope const(char)[]msg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
 pure nothrow @nogc @safe this(stringmsg, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null);
 pure nothrow @nogc @safe this(stringmsg, ThrowablenextInChain, stringfile= __FILE__, size_tline= __LINE__);
- Parameters:const(char)[] msgmessage. No-scope msgis assumed to have the same lifetime as the throwable. scope strings are copied to internal buffer.string filefile name, zero terminated global string size_t lineline number Throwable nextInChainnext exception in the chain (optional) 
- pure this(Args...)(auto ref scope const Argsargs, stringfile= __FILE__, size_tline= __LINE__, ThrowablenextInChain= null)
 if (Args.length > 1 && !is(Args[$ - 1] == Throwable));
- Generic multiargument overload. Constructs a string using the print function.
 
- enum intmaxMirExceptionMsgLen;
Copyright © 2016-2023 by Ilya Yaroshenko | Page generated by
Ddoc on Mon Nov  6 15:24:34 2023