Exception slipping through the catch block?

Mike Parker aldacron at gmail.com
Thu Nov 8 16:13:55 UTC 2018


On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote:
> On Thursday, 8 November 2018 at 15:41:11 UTC, Adam D. Ruppe 
> wrote:
>> On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote:
>>> Shouldn't the catch block in the function catch the exception?
>>
>> You caught Exception, but it throws Error. They have separate 
>> inheritance trees.
>>
>>
>> The common ancestor is actually Throwable, though note that 
>> there is no guarantee that Errors actually unwind the stack; 
>> with certain compile flags they might just abort the program.
>
> Thanks.
>
> 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.


More information about the Digitalmars-d-learn mailing list