On Friday, 15 June 2018 at 17:27:13 UTC, bauss wrote:
On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote:
On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote:
On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis
wrote:
So in case of a thrown Error, you can catch it and log it to
a database.
No, you can't. Once the Error was thrown the program is in
invalid state and you can't assume the logging to database
will succeed.
Sure you can assume it will succeed, BUT in 9/10 cases it will
and in those cases it's worth it.
I do that and it has proven to work every single time for me.
You can't assume it will succeed writing to a log file either.
In either cases you just have to try and hope for the best.
Casting away const 'works' too, but is undefined behavior and is
not guaranteed to work in future implementations.
Likewise, this may work in the current implementation but there's
no guarantee that's to stay.
At the time of throw Error the program must be considered dead.
It sucks, but even if something was logged to the DB you can't
rely on this information to be correct.
Please read Jonathan's posts further up, he explained the
internals and Walter Bright's reasoning in detail.