Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Exception Classes Advice on Subclassesby adrianh (Chancellor) |
on Dec 21, 2005 at 10:16 UTC ( [id://518271]=note: print w/replies, xml ) | Need Help?? |
Hmmm. So I guess my question is, if all those subclasses do the same thing, am I getting anything out of creating them all? You get a more convenient syntax for catching particular exceptions. For example:
much easier than delving into fields to figure out what kind of exception has been thrown. You also get a simple way to represent a hierarchy of exception types. If you have a general ValidationError exception class, with a DateValidation, NameValidation, etc. subclasses then you could capture all of the subclasses with a single ValidationError->caught.
In Section
Seekers of Perl Wisdom
|
|