Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Exception Classes Advice on Subclasses

by venk (Acolyte)
on Dec 21, 2005 at 13:39 UTC ( #518302=note: print w/ replies, xml ) Need Help??


in reply to Exception Classes Advice on Subclasses

I suggest using subclasses rather than trying to differentiate your exceptions through 'fields'.

if ( my $e = X::Class::SubClass1->caught ) { # handle } elsif ( my $e = X::Class::SubClass2->caught ) { # handle }
In each block, the above code directly describes the type of error that it handles --- I think using 'fields' requires the reader to work a little harder to understand what is going on. That said, I recommend not getting carried away with defining complex exception hierarchies. Start with a simple X::Class->caught and subclass only as required by your application.


Comment on Re: Exception Classes Advice on Subclasses
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://518302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-11-27 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (179 votes), past polls