call traceback is indecipherable garbage

WebFreak001 d.forum at webfreak.org
Wed Jan 26 12:17:01 UTC 2022


On Wednesday, 26 January 2022 at 05:17:48 UTC, forkit wrote:
> On Wednesday, 26 January 2022 at 04:25:47 UTC, H. S. Teoh wrote:
>>
>> It's easy, just wrap your main() in a try-catch block:
>>
>> [...]
>
> great!
>
> .. now my 2 little lines of code, has turned into all this 
> peripheral nonesense, just to avoid displaying the useless 
> stack dump.
>
> ;-(
>
> [...]

you could implement a custom _d_print_throwable:

https://github.com/dlang/druntime/blob/33511e263134530a5994a775b03a061ea3f1aa34/src/rt/dmain2.d#L560

This is called on uncaught exceptions, on assert failure and 
other internal fatal errors that exit the program. So make sure 
that the handler itself doesn't crash!

Example: https://run.dlang.io/is/DBhyZW

```d
void main()
{
     throw new Exception("uncaught!");
}

extern (C) void _d_print_throwable(Throwable t) nothrow
{
     import core.stdc.stdio;

     fprintf(stderr, "%.*s", cast(int)t.msg.length, t.msg.ptr);
}
```


More information about the Digitalmars-d mailing list