Re: Error and Exception chaining
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?
Re: Error and Exception chaining
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.
Re: Error and Exception chaining
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
Re: Error and Exception chaining
On 12/12/2016 02:08 PM, Yuxuan Shui wrote: > Thanks a lot for the explanation! > > On Monday, 12 December 2016 at 22:01:54 UTC, Ali Çehreli wrote: >> (Note: Looks like there is a bug regarding Error.bypassedException >> member. Would others please confirm.) >> >> On 12/12/2016 01:15 PM, Yuxuan Shui wrote: >> > [...] >> that Error >> > [...] >> vague, and I'm >> > [...] >> >> You're referring to "[Errors] bypass the normal chaining mechanism, >> such that the chain can only be caught by catching the first Error." >> What it means is that an Error cannot be a collateral of an Exception, >> hiding in its chain. So, when there is an Error that would otherwise >> be a collateral of an Exception, you cannot catch the original >> Exception. What is more importantly in-flight at that time is the Error. >> > > But chaining Error to Error works just like chaining Exception to > Exception? 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 >> But bypassedException member of Error is always null. Bug? > > Did I just randomly found a bug? From what I could graps from that much of documentation, yes, it seems to be a bug. Ali
Re: Error and Exception chaining
Thanks a lot for the explanation! On Monday, 12 December 2016 at 22:01:54 UTC, Ali Çehreli wrote: (Note: Looks like there is a bug regarding Error.bypassedException member. Would others please confirm.) On 12/12/2016 01:15 PM, Yuxuan Shui wrote: > [...] that Error > [...] vague, and I'm > [...] You're referring to "[Errors] bypass the normal chaining mechanism, such that the chain can only be caught by catching the first Error." What it means is that an Error cannot be a collateral of an Exception, hiding in its chain. So, when there is an Error that would otherwise be a collateral of an Exception, you cannot catch the original Exception. What is more importantly in-flight at that time is the Error. But chaining Error to Error works just like chaining Exception to Exception? But bypassedException member of Error is always null. Bug? Did I just randomly found a bug? Thank you, Ali
Error and Exception chaining
I read https://dlang.org/spec/statement.html, which told me that Error is different in the way it's chained. But that is pretty vague, and I'm still confused. Can someone explain that using examples? Thanks.