View mode: basic / threaded / horizontal-split · Log in · Help
October 21, 2012
printing Throwables in druntime
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.
October 21, 2012
Re: printing Throwables in druntime
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!
Top | Discussion index | About this forum | D home