Adding more information to exceptions
Vladimir Panteleev
vladimir at thecybershadow.net
Wed Jan 30 10:48:02 PST 2013
On Tuesday, 29 January 2013 at 20:37:07 UTC, Andrej Mitrovic
wrote:
> On 1/29/13, Vladimir Panteleev <vladimir at thecybershadow.net>
> wrote:
>> foreach (lineNumber, line; lines)
>> try
>> numbers ~= to!int(line);
>> catch (Exception e)
>> throw new Exception(format("Error on line %d: %s",
>> lineNumber, e.msg));
>>
>> Of course, this has the problem that all information (except
>> the
>> message) from the original exception is lost.
>
> What I'd do is:
>
> catch (Exception e)
> {
> e.msg = format("My info here...\n%s", e.msg);
> throw e;
> }
Ah, that's clever... thanks!
More information about the Digitalmars-d-learn
mailing list