www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7540] New: Catch multiple exception types with single catch block

reply d-bugmail puremagic.com writes:
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: yebblies gmail.com
        ReportedBy: yebblies gmail.com



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: -------
Feb 18 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7540


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/738

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