collectExceptionMsg and emptyExceptionMsg

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Apr 18 08:49:55 PDT 2012


Why does collectExceptionMsg return a special 'emptyExceptionMsg'
string if the exception caught has no message?

string collectExceptionMsg(T = Exception, E)(lazy E expression)
{
    try
    {
        expression();

        return cast(string)null;
    }
    catch(T e)
        return e.msg.empty ? emptyExceptionMsg : e.msg;
}
enum emptyExceptionMsg = "<Empty Exception Message>";

I don't see the purpose of this, why not just return an empty string
literal "" which won't be null?


More information about the Digitalmars-d-learn mailing list