digitalmars.D.learn - collectExceptionMsg and emptyExceptionMsg
- Andrej Mitrovic (15/15) Apr 18 2012 Why does collectExceptionMsg return a special '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








Andrej Mitrovic <andrej.mitrovich gmail.com>