Exception chaining and collectException

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 17 15:05:00 PDT 2017


Here's a reduced example that does not depend on std.exception:
-------
import std.stdio;
class MyException : Exception
{
    this() { super("MYMY"); }
}
struct S
{
    ~this()
    {
        try { throw new MyException; }
        catch(MyException e) { writefln("Collected MyException: %s", e.msg); }
        catch(Exception e)   { writefln("Collected Exception: %s",   e.msg); }
    }
    void method() { throw new Exception("Dumb error"); }
}
void main()
{
    try {
        S s;
        s.method();
    } catch(Exception) {}
}
-------

Expected output:
	Collected MyException: MYMY

Actual output:
	Collected Exception: MYMY

Looks like a bug in druntime, or a codegen bug?


T

-- 
Help a man when he is in trouble and he will remember you when he is in trouble again.


More information about the Digitalmars-d mailing list