Chained Catch Statements

Adam D. Ruppe destructionator at gmail.com
Mon Jan 30 06:50:22 PST 2012


On Monday, 30 January 2012 at 14:37:19 UTC, Jared wrote:
> In Java and C++, I can do something to the effect of:

That works in D too.

I believe it does it linearly though, so it will use the
first catch that matches.

try {}
catch (Exception e) {} // most throwable objects derive from 
Exception
catch (SpecialException e) {} // never used, because Exception 
matches it all



Try putting the more specific catches first, and the generic
base classes at the end of the list.



More information about the Digitalmars-d-learn mailing list