Mercurial > projects > mde
view mde/exception.d @ 10:4c3575400769
DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Init threads now catch own exceptions.
Doc: assigned some inputID devisions.
Added support for remaining SDL events.
Input axes' output is now stored with a short instead of a real.
Input unittest written (for SDL event handling).
Rewrote most of mde.mergetag.defaultdata using generic programming to generate read & write rules for all types. As a direct result, defaultdata can now write properly.
DefaultData unittest written (also provides testing for mergetag read/write).
Moved mde.text.parse/format to tango.scrapple.text.convert.parseTo/parseFrom with many changes.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 18 Feb 2008 11:54:56 +0000 |
parents | f63f4f41a2dc |
children | b940f267419e |
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. * A CTOR not taking a message and calling the super without a parameter may also be provided. * * The static 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. (Since only methods overload * correctly, symbol is made static and an overloadable method is used to access the correct symbol.) */ class mdeException : Exception { static const symbol = "mde"; /// Override in derived classes to name the module where the error occured. char[] getSymbol () { return symbol; } this (char[] msg) { super(getSymbol() ~ ": " ~ msg); } this () { // No supplied error message. super(symbol); } } class initException : mdeException { // NOTE: if symbol is final, it can't be modified in the static this(), but as const it can static const char[] symbol; static this () { symbol = super.symbol ~ ".init"; } char[] getSymbol () { return symbol; } this (char[] msg) { super(msg); } } debug (mdeUnitTest) { import tango.util.log.Log : Log, Logger; private Logger logger; static this() { logger = Log.getLogger ("mde.events"); } unittest { // Check message prepending works correctly. mdeException mE = new initException(""); assert (mE.getSymbol() == "mde.init", mE.getSymbol()); try { throw new initException ("ABC"); assert (false); } catch (Exception e) { assert (e.msg == "mde.init: ABC", e.msg); } logger.info ("Unittest complete."); } }