Exception slipping through the catch block?

Stanislav Blinov stanislav.blinov at gmail.com
Thu Nov 8 17:55:45 UTC 2018


On Thursday, 8 November 2018 at 16:13:55 UTC, Mike Parker wrote:
> On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote:

>> Although it's pretty frustrating, isn't it? Now not only I 
>> have to think about catching exceptions but also about Errors, 
>> and have no guarantee that I have everything under control.
>
> No, you should never catch Errors. They're separate for a 
> reason.

Never say never :) There are legitimate cases for catching an 
Error or even a Throwable (for example, error propagation in a 
multi-threaded environment). However, this is not one of such 
cases.

helxi, an AssertError means there's a problem with your code, it 
needs to be dealt with by fixing the code, not swallowing the 
Error.


More information about the Digitalmars-d-learn mailing list