MirException

class MirException : Exception {}

Members

Mixins

__anonymous
mixin MirThrowableImpl

Mixed In Members

From mixin MirThrowableImpl

this
this(const(char)[] msg, string file, size_t line, Throwable nextInChain)
this(const(char)[] msg, Throwable nextInChain, string file, size_t line)
this(string msg, string file, size_t line, Throwable nextInChain)
this(string msg, Throwable nextInChain, string file, size_t line)
~this
~this()
this
this(Args args, string file, size_t line, Throwable nextInChain)

Generic multiargument overload. Constructs a string using the print function.

Examples

Generic style

import mir.exception;
try throw new MirException("Hi D", 2, "!");
catch(Exception e) assert(e.msg == "Hi D2!");

C++ style

import mir.exception;
import mir.format;
try throw new MirException(stringBuf() << "Hi D" << 2 << "!" << getData);
catch(Exception e) assert(e.msg == "Hi D2!");

Low-level style

import mir.exception;
import mir.format;
stringBuf buf;
try throw new MirException(buf.print( "Hi D", 2, "!").data);
catch(Exception e) assert(e.msg == "Hi D2!");
@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);

Meta