printing Throwables in druntime

David d at dav1d.de
Sun Oct 21 09:28:31 PDT 2012


Am 21.10.2012 17:03, schrieb David:
> currently the class Throwable has a member toString which basically
> generates the pretty stacktrace:
> https://github.com/D-Programming-Language/druntime/blob/master/src/object_.d#L1337
>
>
> Now, I tried to override that toString function to get my own
> Exception-Body, but it just didn't call my overriden toString, so
> looking at rt/dmain.d where the Exceptions are print:
>
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L530
>
>
> The Throwable.toString method is never used, but basically reimplemented
> in these print* functions.
>
> What hinders us from replacing:
>
> `print(t);`
>
> with:
>
> `console(t.toString())`?
>
> The only difference I can see is the "bypassed" exception-stuff, but I
> would rather implement that in Throwable.toString. This would also fix
> my problem of not beeing able to change the body of an Exception.

Well, I tried it and implemented it: 
https://github.com/D-Programming-Language/druntime/pull/331

Seems to work!


More information about the Digitalmars-d mailing list