[D-runtime] [D-Programming-Language/druntime] 1117e5: implemented proper exception chaining on Posix
Don Clugston
dclugston at googlemail.com
Wed Mar 30 12:31:33 PDT 2011
On 30 March 2011 20:52, Sean Kelly <sean at invisibleduck.org> wrote:
> On Mar 30, 2011, at 11:18 AM, Sean Kelly wrote:
>>
>> Darnit, I didn't even check for a version switch in eh.d. I'll update and try again.
>
> Alright, this turned out to be an easy problem to fix. I was nulling out the __inflight list when a catch block was entered, and I shouldn't have been. I'm now running into an error much later on, but I don't understand the assert. Here's the code followed by a question:
>
>
> void collideMixed()
> {
> int works = 6;
> try
> {
> try
> {
> try
> {
> throw new Exception("e");
> }
> finally
> {
> throw new Error("t");
> }
> }
> catch(Exception f)
> { // Doesn't catch, because Error is chained to it.
> works += 2;
> }
> }
> catch(Error z)
> {
> works += 4;
> assert(z.msg=="t"); // Error comes first
> assert(z.next is null); // AssertError
> assert(z.bypassedException.msg == "e");
> }
> assert(works == 10);
> }
>
>
> The line labeled "AssertError" is the failure point, but I'm not clear on why this assert is even here. If an Error passes an Exception, is the Exception really not chained to the Error? I guess that makes it easy to determine what's collateral of what, but displaying the error chain may be a tad complicated. Assuming this is desired behavior, how should the chain(s) be displayed?
That's the idea, to preserve the full collateral information.
Out-of-order exception chaining is very confusing if you don't know
that a bypass occured.
It's even more important since other languages do not behave this way.
I envisage displaying something like:
Error: t.
Bypassed Exception e
with the word 'Bypassed' in front of anything which was bypassed at
any level, then go to the 'next' Throwable.
Obviously a complete solution would be to do a tree display, with
indentation to give the nesting level.
But really, the cases where you need a full tree are very obscure.
It's just important to distinguish an original Error with a collateral
Exception, from an original Exception which was bypassed because an
Error happened.
More information about the D-runtime
mailing list