view mde/exception.d @ 7:b544c3a7c9ca

Some changes to exceptions and a few more debug commands. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 16 Jan 2008 12:48:07 +0000
parents 9a990644948c
children f63f4f41a2dc
line wrap: on
line source

/// Contains a base class for all mde exceptions.
module mde.exception;

/** Base class for all mde Exceptions.
 *
 * All packages should have their own base exception type extending this one, and for each package
 * level a CTOR taking a message should pass the message to the super. The const string symbol
 * should be overriden as below so that it ends up as something like "mde.file" or
 * "mde.pkg.file.Class" describing where the exception was thrown.
 * A CTOR not taking a message and calling the super without a parameter may also be provided.
 */
class mdeException : Exception {
    const symbol = "mde";	/// Override in derived classes to name the module where the error occured.
    this (char[] msg) {
        super(symbol ~ ": " ~ msg);
    }
    this () {			// No supplied error message.
        super(symbol);
    }
}

class initException : mdeException {
    const override symbol = super.symbol ~ ".init";
    this (char[] msg) {
        super(msg);
    }
}

class DynamicLibraryLoadException : initException {
    this (char[] msg) {
        super("when loading dynamic library: " ~ msg);
    }
}