Adding more information to exceptions
Andrej Mitrovic
andrej.mitrovich at gmail.com
Tue Jan 29 12:36:58 PST 2013
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;
}
More information about the Digitalmars-d-learn
mailing list