The Proper Use of Exception Chaining: Caught between two conflicting usecases?

Meta jared771 at gmail.com
Fri May 3 14:11:00 UTC 2019


On Friday, 3 May 2019 at 07:12:15 UTC, FeepingCreature wrote:
> On Thursday, 2 May 2019 at 18:34:39 UTC, Meta wrote:
>> I don't understand how what I said contradicts what's on that 
>> page. It seems to agree with what I said, from what I can tell:
>>
>> A reference to the next error in the list. This is used when a 
>> new Throwable is thrown from inside a catch block. The 
>> originally caught Exception will be chained to the new 
>> Throwable via this field
>>
>
> Subtle difference: It says "thrown from inside a *catch* 
> block", but current exception chaining is for exceptions thrown 
> from inside a *finally* block.

Ah, I see.

> Btw, I want to take this opportunity to highlight this 
> wonderful bug I found a few days ago, coincidentally also with 
> exception chaining: 
> https://issues.dlang.org/show_bug.cgi?id=19831 , when you throw 
> *and catch* an exception inside a finally block the runtime 
> gets very confused, and calls the handler for the *chained* 
> exception - but with the *thrown* exception. Fun!

That's a nasty one.


More information about the Digitalmars-d mailing list