Postmortem: Template unittests are bad & you shouldn't catch Error

Paul Backus snarwin at gmail.com
Thu Oct 22 20:33:45 UTC 2020


On Thursday, 22 October 2020 at 20:23:49 UTC, Ali Çehreli wrote:
> On 10/21/20 9:04 PM, Mathias LANG wrote:
>
> > *do not catch Error*. Catching
> > `Error` is a sin, a crime, and every catch of `Error`
> derivative should
> > have you outraged. It is in direct violation of the specs. And
> > obviously, it's also incompatible with scheme that do not
> throw an `Error`.
>
> That's true but I will recommend catching Error in both of my 
> upcoming DConf Online presentations. :)
>
> 1) Thread entry functions should catch and report any 
> Throwable. Otherwise, main thread will see only a timeout and 
> stack trace of the worker will lost.

Once an Error has been thrown, the program is in an invalid 
state, and anything you do *on any thread* has undefined 
behavior. The only thing you can do safely is terminate the 
entire process. Stack traces can be retrieved after the fact from 
a core dump.



More information about the Digitalmars-d mailing list