collectExceptionMsg and emptyExceptionMsg

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Apr 18 10:32:44 PDT 2012


On 4/18/12, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> Probably to avoid any issues of null vs empty

But what I'm saying is an empty string isn't null.

> It also makes it very clear
> that you got an empty exception message when printing the message, whereas
> there won't be any difference between null and empty when you do something
> like
>
> writeln(collectExceptionMessage(foo()));

Well typically you would write the file and line number, or use
specific formatting such as writefln('%s', str).

Think about the opposite, what if I want to provide a default error
message if the exception didn't provide one? It's easier for me to
just use if (str.empty) or if(!str.length) than to do special checks
against 'emptyExceptionMsg'. It seems odd to return a sentry value
instead of a simple empty literal "", no other phobos string function
that I know of uses this technique.


More information about the Digitalmars-d-learn mailing list