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 think you're coming at this with the model that the user can just re-run the program that's thrown the error. But consider long-running services deployed in an enterprise context. In that situation, if an error occurs, there might be quite a long time until you get to see it again - you can't just rerun the program, because the "program" is actually a docker container processing live user data, and you can't just call up your users and tell them "do that thing again" because it may have been many hours ago. In that situation - well, in that situation, usually you will have long ago set that environment variable by default in your reused deployment code. But it's still going to be annoying to the people trying to debug what went wrong there.
On the other hand, with a console app usually the developer will have encountered errors plenty of times during development. So they'll probably have wrapped main with a catch (Throwable) { writeln(Throwable.msg); exit(1); }
or something.
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.