home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Class.pm < prev    next >
Encoding:
Perl POD Document  |  2003-09-25  |  20.1 KB  |  773 lines

  1. package Exception::Class;
  2.  
  3. use 5.005;
  4.  
  5. use strict;
  6. use vars qw($VERSION $BASE_EXC_CLASS %CLASSES);
  7.  
  8. BEGIN { $BASE_EXC_CLASS ||= 'Exception::Class::Base'; }
  9.  
  10. $VERSION = '1.16';
  11.  
  12. sub import
  13. {
  14.     my $class = shift;
  15.  
  16.     local $Exception::Class::Caller = caller();
  17.  
  18.     my %c;
  19.  
  20.     my %needs_parent;
  21.     while (my $subclass = shift)
  22.     {
  23.     my $def = ref $_[0] ? shift : {};
  24.     $def->{isa} = $def->{isa} ? ( ref $def->{isa} ? $def->{isa} : [$def->{isa}] ) : [];
  25.  
  26.         $c{$subclass} = $def;
  27.     }
  28.  
  29.     # We need to sort by length because if we check for keys in the
  30.     # Foo::Bar:: stash, this creates a "Bar::" key in the Foo:: stash!
  31.  MAKE_CLASSES:
  32.     foreach my $subclass ( sort { length $a <=> length $b } keys %c )
  33.     {
  34.         my $def = $c{$subclass};
  35.  
  36.     # We already made this one.
  37.     next if $CLASSES{$subclass};
  38.  
  39.     {
  40.         no strict 'refs';
  41.         foreach my $parent (@{ $def->{isa} })
  42.         {
  43.         unless ( keys %{"$parent\::"} )
  44.         {
  45.             $needs_parent{$subclass} = { parents => $def->{isa},
  46.                          def => $def };
  47.             next MAKE_CLASSES;
  48.         }
  49.         }
  50.     }
  51.  
  52.     $class->_make_subclass( subclass => $subclass,
  53.                 def => $def || {},
  54.                               );
  55.     }
  56.  
  57.     foreach my $subclass (keys %needs_parent)
  58.     {
  59.     # This will be used to spot circular references.
  60.     my %seen;
  61.     $class->_make_parents( \%needs_parent, $subclass, \%seen );
  62.     }
  63. }
  64.  
  65. sub _make_parents
  66. {
  67.     my $class = shift;
  68.     my $needs = shift;
  69.     my $subclass = shift;
  70.     my $seen = shift;
  71.     my $child = shift; # Just for error messages.
  72.  
  73.     no strict 'refs';
  74.  
  75.     # What if someone makes a typo in specifying their 'isa' param?
  76.     # This should catch it.  Either it's been made because it didn't
  77.     # have missing parents OR it's in our hash as needing a parent.
  78.     # If neither of these is true then the _only_ place it is
  79.     # mentioned is in the 'isa' param for some other class, which is
  80.     # not a good enough reason to make a new class.
  81.     die "Class $subclass appears to be a typo as it is only specified in the 'isa' param for $child\n"
  82.     unless exists $needs->{$subclass} || $CLASSES{$subclass} || keys %{"$subclass\::"};
  83.  
  84.     foreach my $c ( @{ $needs->{$subclass}{parents} } )
  85.     {
  86.     # It's been made
  87.     next if $CLASSES{$c} || keys %{"$c\::"};
  88.  
  89.     die "There appears to be some circularity involving $subclass\n"
  90.         if $seen->{$subclass};
  91.  
  92.     $seen->{$subclass} = 1;
  93.  
  94.     $class->_make_parents( $needs, $c, $seen, $subclass );
  95.     }
  96.  
  97.     return if $CLASSES{$subclass} || keys %{"$subclass\::"};
  98.  
  99.     $class->_make_subclass( subclass => $subclass,
  100.                 def => $needs->{$subclass}{def} );
  101. }
  102.  
  103. sub _make_subclass
  104. {
  105.     my $class = shift;
  106.     my %p = @_;
  107.  
  108.     my $subclass = $p{subclass};
  109.     my $def = $p{def};
  110.  
  111.     my $isa;
  112.     if ($def->{isa})
  113.     {
  114.     $isa = ref $def->{isa} ? join ' ', @{ $def->{isa} } : $def->{isa};
  115.     }
  116.     $isa ||= $BASE_EXC_CLASS;
  117.  
  118.     my $code = <<"EOPERL";
  119. package $subclass;
  120.  
  121. use vars qw(\$VERSION);
  122.  
  123. use base qw($isa);
  124.  
  125. \$VERSION = '1.1';
  126.  
  127. 1;
  128.  
  129. EOPERL
  130.  
  131.  
  132.     if ($def->{description})
  133.     {
  134.     (my $desc = $def->{description}) =~ s/([\\\'])/\\$1/g;
  135.     $code .= <<"EOPERL";
  136. sub description
  137. {
  138.     return '$desc';
  139. }
  140. EOPERL
  141.     }
  142.  
  143.     my @fields;
  144.     if ( my $fields = $def->{fields} )
  145.     {
  146.     @fields = UNIVERSAL::isa($fields, 'ARRAY') ? @$fields : $fields;
  147.  
  148.     $code .=
  149.             "sub Fields { return (\$_[0]->SUPER::Fields, " .
  150.             join(", ", map { "'$_'" } @fields) . ") }\n\n";
  151.  
  152.         foreach my $field (@fields)
  153.     {
  154.         $code .= sprintf("sub %s { \$_[0]->{%s} }\n", $field, $field);
  155.     }
  156.     }
  157.  
  158.     if ( my $alias = $def->{alias} )
  159.     {
  160.         die "Cannot make alias without caller"
  161.             unless defined $Exception::Class::Caller;
  162.  
  163.         no strict 'refs';
  164.         *{"$Exception::Class::Caller\::$alias"} = sub { $subclass->throw(@_) };
  165.     }
  166.  
  167.     eval $code;
  168.  
  169.     die $@ if $@;
  170.  
  171.     $CLASSES{$subclass} = 1;
  172. }
  173.  
  174. package Exception::Class::Base;
  175.  
  176. use Class::Data::Inheritable;
  177. use Devel::StackTrace;
  178.  
  179. use base qw(Class::Data::Inheritable);
  180.  
  181. BEGIN
  182. {
  183.     __PACKAGE__->mk_classdata('Trace');
  184.     *do_trace = \&Trace;
  185.     __PACKAGE__->mk_classdata('NoRefs');
  186.     *NoObjectRefs = \&NoRefs;
  187.  
  188.     __PACKAGE__->NoRefs(1);
  189.  
  190.     sub Fields { () }
  191. }
  192.  
  193. use overload
  194.     # an exception is always true
  195.     bool => sub { 1 },
  196.     '""' => 'as_string',
  197.     fallback => 1;
  198.  
  199. use vars qw($VERSION);
  200.  
  201. $VERSION = '1.2';
  202.  
  203. # Create accessor routines
  204. BEGIN
  205. {
  206.     my @fields = qw( message pid uid euid gid egid time trace package file line );
  207.  
  208.     no strict 'refs';
  209.     foreach my $f (@fields)
  210.     {
  211.     *{$f} = sub { my $s = shift; return $s->{$f}; };
  212.     }
  213.     *{'error'} = \&message;
  214. }
  215.  
  216. 1;
  217.  
  218. sub Classes { sort keys %Exception::Class::CLASSES }
  219.  
  220. sub throw
  221. {
  222.     my $proto = shift;
  223.  
  224.     $proto->rethrow if ref $proto;
  225.  
  226.     die $proto->new(@_);
  227. }
  228.  
  229. sub rethrow
  230. {
  231.     my $self = shift;
  232.  
  233.     die $self;
  234. }
  235.  
  236. sub new
  237. {
  238.     my $proto = shift;
  239.     my $class = ref $proto || $proto;
  240.  
  241.     my $self = bless {}, $class;
  242.  
  243.     $self->_initialize(@_);
  244.  
  245.     return $self;
  246. }
  247.  
  248. sub _initialize
  249. {
  250.     my $self = shift;
  251.     my %p = @_ == 1 ? ( error => $_[0] ) : @_;
  252.  
  253.     # Try to get something useful in there (I hope).  Or just give up.
  254.     $self->{message} = $p{message} || $p{error} || $! || '';
  255.  
  256.     $self->{show_trace} = $p{show_trace} if exists $p{show_trace};
  257.  
  258.     # CORE::time is important to fix an error with some versions of
  259.     # Perl
  260.     $self->{time} = CORE::time();
  261.     $self->{pid}  = $$;
  262.     $self->{uid}  = $<;
  263.     $self->{euid} = $>;
  264.     $self->{gid}  = $(;
  265.     $self->{egid} = $);
  266.  
  267.     $self->{trace} =
  268.         Devel::StackTrace->new( ignore_class => __PACKAGE__,
  269.                                 ignore_package => 'Exception::Class',
  270.                                 no_refs => $self->NoRefs,
  271.                               );
  272.  
  273.     if ( my $frame = $self->trace->frame(0) )
  274.     {
  275.         $self->{package} = $frame->package;
  276.         $self->{line} = $frame->line;
  277.         $self->{file} = $frame->filename;
  278.     }
  279.  
  280.     my %fields = map { $_ => 1 } $self->Fields;
  281.     while ( my ($key, $value) = each %p )
  282.     {
  283.        next if $key =~ /^(?:error|message|show_trace)$/;
  284.  
  285.        if ( $fields{$key})
  286.        {
  287.            $self->{$key} = $value;
  288.        }
  289.        else
  290.        {
  291.            Exception::Class::Base->throw
  292.                ( error =>
  293.                  "unknown field $key passed to constructor for class " . ref $self );
  294.        }
  295.     }
  296. }
  297.  
  298. sub description
  299. {
  300.     return 'Generic exception';
  301. }
  302.  
  303. sub show_trace
  304. {
  305.     my $self = shift;
  306.  
  307.     if (@_)
  308.     {
  309.         $self->{show_trace} = shift;
  310.     }
  311.  
  312.     return exists $self->{show_trace} ? $self->{show_trace} : $self->Trace;
  313. }
  314.  
  315. sub as_string
  316. {
  317.     my $self = shift;
  318.  
  319.     my $str = $self->full_message;
  320.     $str .= "\n\n" . $self->trace->as_string
  321.         if $self->show_trace;
  322.  
  323.     return $str;
  324. }
  325.  
  326. sub full_message { $_[0]->{message} }
  327.  
  328. #
  329. # The %seen bit protects against circular inheritance.
  330. #
  331. eval <<'EOF' if $] == 5.006;
  332. sub isa
  333. {
  334.     my ($inheritor, $base) = @_;
  335.     $inheritor = ref($inheritor) if ref($inheritor);
  336.  
  337.     my %seen;
  338.  
  339.     no strict 'refs';
  340.     my @parents = ($inheritor, @{"$inheritor\::ISA"});
  341.     while (my $class = shift @parents)
  342.     {
  343.         return 1 if $class eq $base;
  344.  
  345.         push @parents, grep {!$seen{$_}++} @{"$class\::ISA"};
  346.     }
  347.     return 0;
  348. }
  349. EOF
  350.  
  351. 1;
  352.  
  353. __END__
  354.  
  355. =head1 NAME
  356.  
  357. Exception::Class - A module that allows you to declare real exception classes in Perl
  358.  
  359. =head1 SYNOPSIS
  360.  
  361.   use Exception::Class
  362.       ( 'MyException',
  363.  
  364.         'AnotherException' =>
  365.         { isa => 'MyException' },
  366.  
  367.         'YetAnotherException' =>
  368.         { isa => 'AnotherException',
  369.           description => 'These exceptions are related to IPC' },
  370.  
  371.         'ExceptionWithFields' =>
  372.         { isa => 'YetAnotherException',
  373.           fields => [ 'grandiosity', 'quixotic' ],
  374.           alias => 'throw_fields',
  375.       );
  376.  
  377.   # try
  378.   eval { MyException->throw( error => 'I feel funny.'; };
  379.  
  380.   # catch
  381.   if ( UNIVERSAL::isa( $@, 'MyException' ) )
  382.   {
  383.      warn $@->error, "\n, $@->trace->as_string, "\n";
  384.      warn join ' ',  $@->euid, $@->egid, $@->uid, $@->gid, $@->pid, $@->time;
  385.  
  386.      exit;
  387.   }
  388.   elsif ( UNIVERSAL::isa( $@, 'ExceptionWithFields' ) )
  389.   {
  390.      $@->quixotic ? do_something_wacky() : do_something_sane();
  391.   }
  392.   else
  393.   {
  394.      ref $@ ? $@->rethrow : die $@;
  395.   }
  396.  
  397.   # use an alias - without parens subroutine name is checked at
  398.   # compile time
  399.   throw_fields error => "No strawberry", grandiosity => "quite a bit";
  400.  
  401. =head1 DESCRIPTION
  402.  
  403. Exception::Class allows you to declare exception hierarchies in your
  404. modules in a "Java-esque" manner.
  405.  
  406. It features a simple interface allowing programmers to 'declare'
  407. exception classes at compile time.  It also has a base exception
  408. class, Exception::Class::Base, that can be easily extended.
  409.  
  410. It is designed to make structured exception handling simpler and
  411. better by encouraging people to use hierarchies of exceptions in their
  412. applications, as opposed to a single catch-all exception class.
  413.  
  414. This module does not implement any try/catch syntax.  Please see the
  415. "OTHER EXCEPTION MODULES (try/catch syntax)" section for more
  416. information on how to get this syntax.
  417.  
  418. =head1 DECLARING EXCEPTION CLASSES
  419.  
  420. Importing C<Exception::Class> allows you to automagically create
  421. C<Exception::Class::Base> subclasses.  You can also create subclasses
  422. via the traditional means of defining your own subclass with C<@ISA>.
  423. These two methods may be easily combined, so that you could subclass
  424. an exception class defined via the automagic import, if you desired
  425. this.
  426.  
  427. The syntax for the magic declarations is as follows:
  428.  
  429. 'MANDATORY CLASS NAME' => \%optional_hashref
  430.  
  431. The hashref may contain the following options:
  432.  
  433. =over 4
  434.  
  435. =item * isa
  436.  
  437. This is the class's parent class.  If this isn't provided then the
  438. class name in C<$Exception::Class::BASE_EXC_CLASS> is assumed to be
  439. the parent (see below).
  440.  
  441. This parameter lets you create arbitrarily deep class hierarchies.
  442. This can be any other C<Exception::Class::Base> subclass in your
  443. declaration I<or> a subclass loaded from a module.
  444.  
  445. To change the default exception class you will need to change the
  446. value of C<$Exception::Class::BASE_EXC_CLASS> I<before> calling C<import>.
  447. To do this simply do something like this:
  448.  
  449. BEGIN { $Exception::Class::BASE_EXC_CLASS = 'SomeExceptionClass'; }
  450.  
  451. If anyone can come up with a more elegant way to do this please let me
  452. know.
  453.  
  454. CAVEAT: If you want to automagically subclass an
  455. C<Exception::Class::Base> subclass loaded from a file, then you
  456. I<must> compile the class (via use or require or some other magic)
  457. I<before> you import C<Exception::Class> or you'll get a compile time
  458. error.
  459.  
  460. =item * fields
  461.  
  462. This allows you to define additional attributes for your exception
  463. class.  Any field you define can be passed to the C<throw> or C<new>
  464. methods as additional parameters for the constructor.  In addition,
  465. your exception object will have an accessor method for the fields you
  466. define.
  467.  
  468. This parameter can be either a scalar (for a single field) or an array
  469. reference if you need to define multiple fields.
  470.  
  471. Fields will be inherited by subclasses.
  472.  
  473. =item * alias
  474.  
  475. Specifying an alias causes this class to create a subroutine of the
  476. specified name in the I<caller's> namespace.  Calling this subroutine
  477. is equivalent to calling C<< <class>->throw(@_) >> for the given
  478. exception class.
  479.  
  480. Besides convenience, using aliases also allows for additional compile
  481. time checking.  If the alias is called I<without parentheses>, as in
  482. C<throw_fields "an error occurred">, then Perl checks for the
  483. existence of the C<throw_fields()> subroutine at compile time.  If
  484. instead you do C<< ExceptionWithFields->throw(...) >>, then Perl
  485. checks the class name at runtime, meaning that typos may sneak
  486. through.
  487.  
  488. =item * description
  489.  
  490. Each exception class has a description method that returns a fixed
  491. string.  This should describe the exception I<class> (as opposed to
  492. any particular exception object).  This may be useful for debugging if
  493. you start catching exceptions you weren't expecting (particularly if
  494. someone forgot to document them) and you don't understand the error
  495. messages.
  496.  
  497. =back
  498.  
  499. The C<Exception::Class> magic attempts to detect circular class
  500. hierarchies and will die if it finds one.  It also detects missing
  501. links in a chain, for example if you declare Bar to be a subclass of
  502. Foo and never declare Foo.
  503.  
  504. =head1 Exception::Class::Base CLASS METHODS
  505.  
  506. =over 4
  507.  
  508. =item * Classes
  509.  
  510. Returns a list of the classes that have been defined as subclasses of
  511. Exception::Class.  Note that this is I<all> the subclasses that have
  512. been created, so it may include subclasses created by things like CPAN
  513. modules, etc.
  514.  
  515. =item * Trace($boolean)
  516.  
  517. Each C<Exception::Class::Base> subclass can be set individually to
  518. include a a stracktrace when the C<as_string> method is called.  The
  519. default is to not include a stacktrace.  Calling this method with a
  520. value changes this behavior.  It always returns the current value
  521. (after any change is applied).
  522.  
  523. This value is inherited by any subclasses.  However, if this value is
  524. set for a subclass, it will thereafter be independent of the value in
  525. C<Exception::Class::Base>.
  526.  
  527. This is a class method, not an object method.
  528.  
  529. =item * NoRefs($boolean)
  530.  
  531. When a C<Devel::StackTrace> is created, it walks through the stack and
  532. stores the arguments which were passed to each subroutine on the
  533. stack.  If any of these arguments are references, then that means that
  534. the C<Devel::StackTrace> ends up increasing the refcount of these
  535. references, delaying their destruction.
  536.  
  537. Since C<Exception::Class::Base> uses C<Devel::StackTrace> internally,
  538. this method provides a way to tell C<Devel::StackTrace> not to store
  539. these references.  Instead, C<Devel::StackTrace> replaces references
  540. with their stringified representation.
  541.  
  542. This method defaults to true.  As with C<Trace>, it is inherited by
  543. subclasses but setting it in a subclass makes it independent
  544. thereafter.
  545.  
  546. =item * Fields
  547.  
  548. This method returns the extra fields defined for the given class, as
  549. an array.
  550.  
  551. =item * throw( $message )
  552.  
  553. =item * throw( message => $message )
  554.  
  555. =item * throw( error => $error )
  556.  
  557. This method creates a new C<Exception::Class::Base> object with the
  558. given error message.  If no error message is given, C<$!> is used.  It
  559. then die's with this object as its argument.
  560.  
  561. This method also takes a C<show_trace> parameter which indicates
  562. whether or not the particular exception object being created should
  563. show a stacktrace when its C<as_string> method is called.  This
  564. overrides the value of C<Trace> for this class if it is given.
  565.  
  566. If only a single value is given to the constructor it is assumed to be
  567. the message parameter.
  568.  
  569. Additional keys corresponding to the fields defined for the particular
  570. exception subclass will also be accepted.
  571.  
  572. =item * new
  573.  
  574. This method takes the same parameters as C<throw>, but instead of
  575. dying simply returns a new exception object.
  576.  
  577. =item * description
  578.  
  579. Returns the description for the given C<Exception::Class::Base>
  580. subclass.  The C<Exception::Class::Base> class's description is
  581. "Generic exception" (this may change in the future).  This is also an
  582. object method.
  583.  
  584. =back
  585.  
  586. =head1 Exception::Class::Base OBJECT METHODS
  587.  
  588. =over 4
  589.  
  590. =item * rethrow
  591.  
  592. Simply dies with the object as its sole argument.  It's just syntactic
  593. sugar.  This does not change any of the object's attribute values.
  594. However, it will cause C<caller> to report the die as coming from
  595. within the C<Exception::Class::Base> class rather than where rethrow
  596. was called.
  597.  
  598. Of course, you always have access to the original stacktrace for the
  599. exception object.
  600.  
  601. =item * message
  602.  
  603. =item * error
  604.  
  605. Returns the error/message associated with the exception.
  606.  
  607. =item * pid
  608.  
  609. Returns the pid at the time the exception was thrown.
  610.  
  611. =item * uid
  612.  
  613. Returns the real user id at the time the exception was thrown.
  614.  
  615. =item * gid
  616.  
  617. Returns the real group id at the time the exception was thrown.
  618.  
  619. =item * euid
  620.  
  621. Returns the effective user id at the time the exception was thrown.
  622.  
  623. =item * egid
  624.  
  625. Returns the effective group id at the time the exception was thrown.
  626.  
  627. =item * time
  628.  
  629. Returns the time in seconds since the epoch at the time the exception
  630. was thrown.
  631.  
  632. =item * package
  633.  
  634. Returns the package from which the exception was thrown.
  635.  
  636. =item * file
  637.  
  638. Returns the file within which the exception was thrown.
  639.  
  640. =item * line
  641.  
  642. Returns the line where the exception was thrown.
  643.  
  644. =item * trace
  645.  
  646. Returns the trace object associated with the object.
  647.  
  648. =item * show_trace($boolean)
  649.  
  650. This method can be used to set whether or not a strack trace is
  651. included when the as_string method is called or the object is
  652. stringified.
  653.  
  654. =item * as_string
  655.  
  656. Returns a string form of the error message (something like what you'd
  657. expect from die).  If the class or object is set to show traces then
  658. then the full trace is also included.  The result looks like
  659. C<Carp::confess>.
  660.  
  661. =item * full_message
  662.  
  663. Called by the C<as_string> method to get the message.  By default,
  664. this is the same as calling the C<message> method, but may be
  665. overridden by a subclass.  See below for details.
  666.  
  667. =back
  668.  
  669. =head1 OVERLOADING
  670.  
  671. The C<Exception::Class::Base> object is overloaded so that
  672. stringification produces a normal error message.  It just calls the
  673. as_string method described above.  This means that you can just
  674. C<print $@> after an eval and not worry about whether or not its an
  675. actual object.  It also means an application or module could do this:
  676.  
  677.  $SIG{__DIE__} = sub { Exception::Class::Base->throw( error => join '', @_ ); };
  678.  
  679. and this would probably not break anything (unless someone was
  680. expecting a different type of exception object from C<die>).
  681.  
  682. =head1 OVERRIDING THE as_string METHOD
  683.  
  684. By default, the C<as_string> method simply returns the value
  685. C<message> or C<error> param plus a stack trace, if the class's
  686. C<Trace> method returns a true value or C<show_trace> was set when
  687. creating the exception.
  688.  
  689. However, once you add new fields to a subclass, you may want to
  690. include those fields in the stringified error.
  691.  
  692. Inside the C<as_string> method, the message (non-stack trace) portion
  693. of the error is generated by calling the C<full_message> method.  This
  694. can be easily overridden.  For example:
  695.  
  696.   sub full_message
  697.   {
  698.       my $self = shift;
  699.  
  700.       my $msg = $self->message;
  701.  
  702.       $msg .= " and foo was " . $self->foo;
  703.  
  704.       return $msg;
  705.   }
  706.  
  707. =head1 USAGE RECOMMENDATION
  708.  
  709. If you're creating a complex system that throws lots of different
  710. types of exceptions, consider putting all the exception declarations
  711. in one place.  For an app called Foo you might make a
  712. C<Foo::Exceptions> module and use that in all your code.  This module
  713. could just contain the code to make C<Exception::Class> do its
  714. automagic class creation.  Doing this allows you to more easily see
  715. what exceptions you have, and makes it easier to keep track of them.
  716.  
  717. This might look something like this:
  718.  
  719.   package Foo::Bar::Exceptions;
  720.  
  721.   use Exception::Class ( Foo::Bar::Exception::Senses =>
  722.                         { description => 'sense-related exception' },
  723.  
  724.                          Foo::Bar::Exception::Smell =>
  725.                          { isa => 'Foo::Bar::Exception::Senses',
  726.                            fields => 'odor',
  727.                            description => 'stinky!' },
  728.  
  729.                          Foo::Bar::Exception::Taste =>
  730.                          { isa => 'Foo::Bar::Exception::Senses',
  731.                            fields => [ 'taste', 'bitterness' ],
  732.                            description => 'like, gag me with a spoon!' },
  733.  
  734.                          ... );
  735.  
  736. You may want to create a real module to subclass
  737. C<Exception::Class::Base> as well, particularly if you want your
  738. exceptions to have more methods.
  739.  
  740. =head1 OTHER EXCEPTION MODULES (try/catch syntax)
  741.  
  742. If you are interested in adding try/catch/finally syntactic sugar to
  743. your code then I recommend you check out U. Arun Kumar's C<Error.pm>
  744. module, which implements this syntax.  It also includes its own base
  745. exception class, C<Error::Simple>.
  746.  
  747. If you would prefer to use the C<Exception::Class::Base> class
  748. included with this module, you'll have to add this to your code
  749. somewhere:
  750.  
  751.   push @Exception::Class::Base::ISA, 'Error';
  752.  
  753. It's a hack but apparently it works.
  754.  
  755. =head1 AUTHOR
  756.  
  757. Dave Rolsky, <autarch@urth.org>
  758.  
  759. =head1 SEE ALSO
  760.  
  761. Devel::StackTrace - used by this module to create stack traces
  762.  
  763. Error.pm - implements try/catch in Perl.  Also provides an exception
  764. base class.
  765.  
  766. Test::Exception - a module that helps you test exception based code.
  767.  
  768. Numerous other modules/frameworks seem to have their own exception
  769. classes (SPOPS and Template Toolkit, to name two) but none of these
  770. seem to be designed for use outside of these packages.
  771.  
  772. =cut
  773.