February 01, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Monday, 31 January 2022 at 09:42:27 UTC, forkit wrote:
> On Monday, 31 January 2022 at 08:56:17 UTC, FeepingCreature wrote:
>>
>> I think this is not a good idea. This sounds like the sort of environment variable that you usually, when it matters, want to *have set* a while ago, rather than set that moment. It's just one more "gotcha that you just need to know to work with the language."
>
> so that 'gotcha' is easily solved.
>
> when an error is printed, on the next line it could say this:
>
> =========================
>
> std.exception.ErrnoException@std\stdio.d(545): Cannot open file `nosuchfile' in mode `rb' (No such file or directory)
>
> ------------------------------------------------------------------
> To see stack backtrace, set evironment variable: DLANG_BACKTRACE=1
>
>
> =============================================
I would much rather that you disable stacktraces rather than enables them.
I have systems running for months without being able to just rerun on the fly when it fails.
Without a stacktrace that would fail and I most definitely wouldn't remember to enable that for every program I run.
|
February 01, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Monday, 31 January 2022 at 20:43:21 UTC, forkit wrote:
> On Monday, 31 January 2022 at 15:57:44 UTC, FeepingCreature wrote:
>
>> I think it's better by default to give more info rather than less. You can always ignore stuff you don't care about; you can't anti-ignore stuff that was never printed.
>
> Knowing what frames are on the call stack when an exception is caught by the runtime is a 'debugging aid'. I do not see the case for having it printed by default, resulting in end-users trying to decipher it's nonsense.
End-users are not supposed to decipher this nonsense. They are supposed to paste it in a bugreport reported against your application, so that you can decipher it. Some applications even have built-in pop-up dialogs, suggesting the user to send a crash report to developers with just a single button click.
|
February 04, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Wednesday, 26 January 2022 at 21:11:42 UTC, H. S. Teoh wrote: > On Wed, Jan 26, 2022 at 09:02:09PM +0000, forkit via Digitalmars-d wrote: >> 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. > [...] > > File this as an enhancement request, it might be worth implementing. One can easily disable any exception traces via https://dlang.org/phobos/core_runtime.html#.Runtime.traceHandler: ``` void main() { import core.runtime : Runtime; Runtime.traceHandler = null; throw new Exception("oops"); } ``` [That won't just avoid the output, but also makes EH faster.] One can also set a custom function, e.g., to make tracing depend on some environment variable, reusing https://dlang.org/phobos/core_runtime.html#.defaultTraceHandler. |
February 04, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Friday, 4 February 2022 at 19:04:24 UTC, kinke wrote:
>
> One can easily disable any exception traces via https://dlang.org/phobos/core_runtime.html#.Runtime.traceHandler:
> ```
> void main() {
> import core.runtime : Runtime;
> Runtime.traceHandler = null;
>
> throw new Exception("oops");
> }
> ```
>
> [That won't just avoid the output, but also makes EH faster.]
>
> One can also set a custom function, e.g., to make tracing depend on some environment variable, reusing https://dlang.org/phobos/core_runtime.html#.defaultTraceHandler.
Thanks. Very useful info :-)
Although, I almost always need to compile with '-g' in order for the strace to be of any practical use.
So I will likely end up incorporating above, into this:
debug
{
import core.runtime : Runtime;
Runtime.traceHandler = null;
}
|
February 04, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Friday, 4 February 2022 at 22:47:18 UTC, forkit wrote:
>
> Thanks. Very useful info :-)
>
> Although, I almost always need to compile with '-g' in order for the strace to be of any practical use.
>
> So I will likely end up incorporating above, into this:
>
> debug
> {
> import core.runtime : Runtime;
> Runtime.traceHandler = null;
> }
oops. of course I meant:
!debug
{
import core.runtime : Runtime;
Runtime.traceHandler = null;
}
btw. how do I do that exactly (ie. !debug)
|
February 04, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Friday, 4 February 2022 at 22:50:12 UTC, forkit wrote:
>
> btw. how do I do that exactly (ie. !debug)
this seems messy:
debug
{
}
else
{
import core.runtime : Runtime;
Runtime.traceHandler = null;
}
!debug would be much nicer.
|
February 04, 2022 Re: call traceback is indecipherable garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to forkit | On Fri, Feb 04, 2022 at 10:50:12PM +0000, forkit via Digitalmars-d wrote: [...] > btw. how do I do that exactly (ie. !debug) version(debug) {} else { ... // non-debug stuff goes here } If you don't like that, e.g. if you have to do this many times in your code, you could do something like this: // Do this once version(debug) enum isDebug = true; else enum isDebug = false; ... // Do this whenever you need static if (!isDebug) { ... // non-debug stuff here } T -- Guns don't kill people. Bullets do. |
Copyright © 1999-2021 by the D Language Foundation