Exception::Base

Exception::Base is a Perl module with lightweight exceptions.
Download

Exception::Base Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Piotr Roszatycki
  • Publisher web site:
  • http://search.cpan.org/~dexter/MooseX-GlobRef-Object-0.02/lib/MooseX/GlobRef/Object.pm

Exception::Base Tags


Exception::Base Description

Exception::Base is a Perl module with lightweight exceptions. Exception::Base is a Perl module with lightweight exceptions.SYNOPSIS # Use module and create needed exceptions use Exception::Base ( 'Exception::IO', 'Exception::FileNotFound' => { message => 'File not found', isa => 'Exception::IO' }, ); # try / catch try Exception eval { do_something() or throw Exception::FileNotFound message=>'Something wrong', tag=>'something'; }; # Catch the Exception::Base, other exceptions throw immediately if (catch Exception::Base my $e) { # $e is an exception object for sure, no need to check if is blessed if ($e->isa('Exception::IO')) { warn "IO problem"; } elsif ($e->isa('Exception::Die')) { warn "eval died"; } elsif ($e->isa('Exception::Warn')) { warn "some warn was caught"; } elsif ($e->with(tag=>'something')) { warn "something happened"; } elsif ($e->with(qr/^Error/)) { warn "some error based on regex"; } else { $e->throw; } # rethrow the exception } # the exception can be thrown later $e = new Exception::Base; $e->throw; # try with array context @v = try Exception::Base ; # use syntactic sugar use Exception::Base qw, 'Exception::IO'; try eval { throw Exception::IO; }; # don't forget about semicolon catch my $e, ; # Exception::Base is by defaultThis class implements a fully OO exception mechanism similar to Exception::Class or Class::Throwable. It does not depend on other modules like Exception::Class and it is more powerful than Class::Throwable. Also it does not use closures as Error and does not polute namespace as Exception::Class::TryCatch. It is also much faster than Exception::Class. Here are some key features of "Exception::Base": · fast implementation of an exception object · fully OO without closures and source code filtering · does not mess with $SIG{__DIE__} and $SIG{__WARN__} · no external modules dependencies, requires core Perl modules only · implements error stack, the try/catch blocks can be nested · shows full backtrace stack on die by default · the default behaviour of exception class can be changed globally or just for the thrown exception · the exception can be created with defined custom properties · matching the exception by class, message or custom properties · matching with string, regex or closure function · creating automatically the derived exception classes ("use" interface) · easly expendable, see Exception::System class for example Requirements: · Perl


Exception::Base Related Software