Exception::Class

Exception::Class is a Perl module that allows you to declare real exception classes in Perl.
Download

Exception::Class Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Dave Rolsky
  • Publisher web site:
  • http://search.cpan.org/~drolsky/

Exception::Class Tags


Exception::Class Description

Exception::Class is a Perl module that allows you to declare real exception classes in Perl. Exception::Class is a Perl module that allows you to declare real exception classes in Perl.SYNOPSIS use Exception::Class ( 'MyException', 'AnotherException' => { isa => 'MyException' }, 'YetAnotherException' => { isa => 'AnotherException', description => 'These exceptions are related to IPC' }, 'ExceptionWithFields' => { isa => 'YetAnotherException', fields => , alias => 'throw_fields', }, ); # try eval { MyException->throw( error => 'I feel funny.' ) }; my $e; # catch if ( $e = Exception::Class->caught('MyException') ) { warn $e->error, "n", $e->trace->as_string, "n"; warn join ' ', $e->euid, $e->egid, $e->uid, $e->gid, $e->pid, $e->time; exit; } elsif ( $e = Exception::Class->caught('ExceptionWithFields') ) { $e->quixotic ? do_something_wacky() : do_something_sane(); } else { $e = Exception::Class->caught(); ref $e ? $e->rethrow : die $e; } # use an alias - without parens subroutine name is checked at # compile time throw_fields error => "No strawberry", grandiosity => "quite a bit";Exception::Class allows you to declare exception hierarchies in your modules in a "Java-esque" manner.It features a simple interface allowing programmers to 'declare' exception classes at compile time. It also has a base exception class, Exception::Class::Base, that can be easily extended.It is designed to make structured exception handling simpler and better by encouraging people to use hierarchies of exceptions in their applications, as opposed to a single catch-all exception class.This module does not implement any try/catch syntax. Please see the "OTHER EXCEPTION MODULES (try/catch syntax)" section for more information on how to get this syntax. Requirements: · Perl


Exception::Class Related Software