http://d.puremagic.com/issues/show_bug.cgi?id=7540

           Summary: Catch multiple exception types with single catch block
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: yebbl...@gmail.com
        ReportedBy: yebbl...@gmail.com


--- Comment #0 from yebblies <yebbl...@gmail.com> 2012-02-19 18:47:51 EST ---
In some cases, multiple exceptions require the exact same handling code in a
catch block, but are not the only children of a common base class.

class MyExceptionA : Exception {}
class MyExceptionB : Exception {}
class MyExceptionC : Exception {}

void main()
{
    try
    {
        trySomething();
    }
    catch (e : MyExceptionA, MyExceptionB)
    {
        // handle A and B
    }
    catch (MyExceptionC e)
    {
        // handle C a different way
    }
}

This avoid the current messy solutions such as duplicating the bodies, using
goto (does this even work?), moving the code to a function, or catching the
base class and using typeinfo to choose.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to