<?xml version="1.0" encoding="windows-1252"?>
<node id="518302" title="Re: Exception Classes Advice on Subclasses" created="2005-12-21 08:39:31" updated="2005-12-21 03:39:31">
<type id="11">
note</type>
<author id="478719">
venk</author>
<data>
<field name="doctext">
I suggest using subclasses rather than trying to differentiate your
exceptions through 'fields'.

&lt;code&gt;
if ( my $e = X::Class::SubClass1-&gt;caught ) {
    # handle
}
elsif ( my $e = X::Class::SubClass2-&gt;caught ) {
    # handle
}
&lt;/code&gt;

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 &lt;code&gt;X::Class-&gt;caught&lt;/code&gt; and
subclass only as required by your application.




</field>
<field name="root_node">
518228</field>
<field name="parent_node">
518228</field>
</data>
</node>
