January 26, 2022
On Wednesday, 26 January 2022 at 03:33:31 UTC, H. S. Teoh wrote:
>
> Running with `dmd -g -run test.d` produces:
>
> ....
>
> T

Interesting. Thanks for mentioning that -g option.

Still, it makes complete sense to me, that a stack trace dump is 'debugging material', and that -release should print only the exeption, and nothing else.

Surely I'm not the only one who has come to that conclusion :-(

January 26, 2022
On Wednesday, 26 January 2022 at 03:45:01 UTC, Steven Schveighoffer wrote:
>
> Regardless of the "correct" way to deal with this, I agree with you that printing code addresses is not helpful. I'm assuming this is Windows? Is there nothing better that can be done?
>
> -Steve

You mean stop using Windows?
January 25, 2022

On 1/25/22 10:56 PM, forkit wrote:

>

On Wednesday, 26 January 2022 at 03:45:01 UTC, Steven Schveighoffer wrote:

>

Regardless of the "correct" way to deal with this, I agree with you that printing code addresses is not helpful. I'm assuming this is Windows? Is there nothing better that can be done?

You mean stop using Windows?

No I mean, on Windows, is there no better thing to print out for a stack frame other than the address? Not a question aimed at you ;)

If I don't include debug info for Mac (even if I strip the executable), I still get function names, but not file/line info.

I'm pretty sure Windows isn't the only OS that does this by default, but I can't remember all the different OSes I've tried D on.

-Steve

January 25, 2022
On Wed, Jan 26, 2022 at 03:51:55AM +0000, forkit via Digitalmars-d wrote: [...]
> Still, it makes complete sense to me, that a stack trace dump is 'debugging material', and that -release should print only the exeption, and nothing else.

It's easy, just wrap your main() in a try-catch block:

	int main() {
		try {
			// ... rest of code goes here
			return 0;
		} catch(Exception e) {
			writeln("Error: %s", e.msg);
			return 1;
		}
	}


T

-- 
Your inconsistency is the only consistent thing about you! -- KD
January 26, 2022

On Wednesday, 26 January 2022 at 02:20:17 UTC, forkit wrote:

>

has anyone ever considered getting rid of the indecipherable

Forum oriented programming.

January 26, 2022
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:
>
> 	int main() {
> 		try {
> 			// ... rest of code goes here
> 			return 0;
> 		} catch(Exception e) {
> 			writeln("Error: %s", e.msg);
> 			return 1;
> 		}
> 	}
>
>
> T

great!

.. now my 2 little lines of code, has turned into all this peripheral nonesense, just to avoid displaying the useless stack dump.

;-(

// --
module test;
import std;

int main()
{
    try
    {
        auto f = File("d://tewxt.txt").byLine;
        f.take(1).each!writeln;

        return 0;
    }
    catch(Exception e)
    {
        writeln("Error: %s", e.msg);
        return 1;
    }
}
// ---
January 26, 2022
On Wednesday, 26 January 2022 at 05:17:48 UTC, forkit wrote:

>
> .. now my 2 little lines of code, has turned into all this peripheral nonesense, just to avoid displaying the useless stack dump.

There is currently an open bug which prevents a stack trace - just link a DLL statically with an initialized runtime in it :D
https://issues.dlang.org/show_bug.cgi?id=22181
January 26, 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

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);
}
January 26, 2022

On Wednesday, 26 January 2022 at 03:51:55 UTC, forkit wrote:

>

Still, it makes complete sense to me, that a stack trace dump is 'debugging material', and that -release should print only the exeption, and nothing else.

Surely I'm not the only one who has come to that conclusion :-(

https://forum.dlang.org/post/m09gue$38e$1@digitalmars.com

I wouldn't be against only printing the Exception message by default either, but others consider letting an Exception escape main a bug, and think you should explicitly catch Exceptions that you expect might be thrown.

January 26, 2022
On Wednesday, 26 January 2022 at 02:20:17 UTC, forkit wrote:
>
btw. I really like how Rust does it:

just set an environment variable (set RUST_BACKTRACE=1)

then run your program, and it will dump the backtrace, when you run your program.