Error and Exception chaining

Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 12 17:23:17 PST 2016


On Tuesday, 13 December 2016 at 00:33:58 UTC, Yuxuan Shui wrote:
> On Monday, 12 December 2016 at 22:35:22 UTC, Yuxuan Shui wrote:
>> On Monday, 12 December 2016 at 22:13:59 UTC, Ali Çehreli wrote:
>>> On 12/12/2016 02:08 PM, Yuxuan Shui wrote:
>>> > [...]
>>> wrote:
>>> >> [...]
>>> Error.bypassedException
>>> >> [...]
>>> mechanism,
>>> >> [...]
>>> Error."
>>> >> [...]
>>> Exception,
>>> >> [...]
>>> otherwise
>>> >> [...]
>>> original
>>> >> [...]
>>> is the Error.
>>> > [...]
>>> Exception to
>>> > [...]
>>>
>>> Currently yes. Now this line in my versatile :o) program:
>>>
>>>             if (n >= errorIndex) {
>>>
>>> Two Errors are chained:
>>>
>>> Caught
>>> TestError: 3
>>>  TestError: 4
>>>
>>> However, there is the following ongoing thread claiming that 
>>> it was a wrong decision:
>>>
>>>   http://forum.dlang.org/post/o2n347$2i1g$1@digitalmars.com
>>>
>>> > [...]
>>>
>>> From what I could graps from that much of documentation, yes, 
>>> it seems to be a bug.
>>
>> I did some testing and bypassedException is null in 2.072.1, 
>> but is not null in 2.070.2
>>
>>>
>>> Ali
>
> The unwind process seem to stop one level too early, causing 
> language_specific_data to be different, causing 
> __dmd_personality_v0 to not chain exception into 
> .bypassException.

OK. I think I figured it out. catch(Error x) won't catch 
TestException, so TestException 0,1,2 is not handled at main(). 
However TestError 3 (and TestExcepotion 4 which is chained to it) 
is handled at main(). And dmd won't put Throwables that are 
handled at different places together.

This behavior seems reasonable. So maybe this is actually a bug 
is LDC?


More information about the Digitalmars-d-learn mailing list