digitalmars.D.bugs - [Issue 7540] New: Catch multiple exception types with single catch block
- d-bugmail puremagic.com (39/39) Feb 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7540
- d-bugmail puremagic.com (10/10) Feb 19 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7540
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 --- Comment #0 from yebblies <yebblies 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: -------
Feb 18 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7540 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from yebblies <yebblies gmail.com> 2012-02-19 23:48:38 EST --- 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