[D-runtime] [D-Programming-Language/druntime] 1117e5: implemented proper exception chaining on Posix

Sean Kelly sean at invisibleduck.org
Wed Mar 30 11:52:15 PDT 2011


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?


More information about the D-runtime mailing list