Mercurial > projects > mde
diff mde/exception.d @ 25:2c28ee04a4ed
Some minor and some futile efforts.
Played around with init functions, had problems, gave up and put them back.
Removed idea for multiple init stages; it's not good for performance or simplicity.
Adjusted exception messages.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 03 Apr 2008 17:26:52 +0100 |
parents | 838577503598 |
children | 611f7b9063c6 |
line wrap: on
line diff
--- a/mde/exception.d Thu Mar 27 16:15:21 2008 +0000 +++ b/mde/exception.d Thu Apr 03 17:26:52 2008 +0100 @@ -27,26 +27,27 @@ * "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. + class mdeException : Exception { + /// Override in derived classes to name the module where the error occured. char[] getSymbol () { - return symbol; + return "mde"; + } + /// Prefix msg, e.g.: "mde.foo: message" + char[] prefixedMsg () { + return getSymbol() ~ ": " ~ msg; } this (char[] msg) { - super(getSymbol() ~ ": " ~ msg); + super(msg); } this () { // No supplied error message. - super(symbol); + super(""); } } /// Thrown when loading options fails. class optionsLoadException : 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 ~ ".options"; } char[] getSymbol () { - return symbol; + return super.getSymbol ~ ".options"; } this (char[] msg) { @@ -56,11 +57,8 @@ /// Thrown when loading strings for the requested name and current locale fails. class L10nLoadException : 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 ~ ".i18n.I18nTranslation"; } char[] getSymbol () { - return symbol; + return super.getSymbol ~ ".i18n.I18nTranslation"; } this (char[] msg) {