http://qs1969.pair.com?node_id=518302


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.