www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - collectExceptionMsg and emptyExceptionMsg

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?
Apr 18 2012