Exception::Class::TryCatch

Exception::Class::TryCatch is a syntactic try/catch sugar for use with Exception::Class.
Download

Exception::Class::TryCatch Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David A Golden
  • Publisher web site:
  • http://search.cpan.org/~dagolden/Statistics-RankOrder-0.12/lib/Statistics/RankOrder.pm

Exception::Class::TryCatch Tags


Exception::Class::TryCatch Description

Exception::Class::TryCatch is a syntactic try/catch sugar for use with Exception::Class. Exception::Class::TryCatch is a syntactic try/catch sugar for use with Exception::Class.SYNOPSIS use Exception::Class::TryCatch; # simple usage of catch() eval { Exception::Class::Base->throw('error') }; catch my $err and warn $err->error; # catching only certain types or else rethrowing eval { Exception::Class::Base::SubClass->throw('error') }; catch( my $err, ) and warn $err->error; # catching and handling different types of errors eval { Exception::Class::Base->throw('error') }; if ( catch my $err ) { $err->isa('this') and do { handle_this($err) }; $err->isa('that') and do { handle_that($err) }; } # use "try eval" to push exceptions onto a stack to catch later try eval { Exception::Class::Base->throw('error') }; do { # cleanup that might use "try/catch" again }; catch my $err; # catches a matching "try"Exception::Class::TryCatch provides syntactic sugar for use with Exception::Class using the familiar keywords try and catch. Its primary objective is to allow users to avoid dealing directly with $@ by ensuring that any exceptions caught in an eval are captured as Exception::Class objects, whether they were thrown objects to begin with or whether the error resulted from die. This means that users may immediately use isa and various Exception::Class methods to process the exception.In addition, this module provides for a method to push errors onto a hidden error stack immediately after an eval so that cleanup code or other error handling may also call eval without the original error in $@ being lost.Inspiration for this module is due in part to Dave Rolsky's article "Exception Handling in Perl With Exception::Class" in The Perl Journal (Rolsky 2004).The try/catch syntax used in this module does not use code reference prototypes the way the Error.pm module does, but simply provides some helpful functionality when used in combination with eval. As a result, it avoids the complexity and dangers involving nested closures and memory leaks inherent in Error.pm (Perrin 2003).Rolsky (2004) notes that these memory leaks may not occur in recent versions of Perl, but the approach used in Exception::Class::TryCatch should be safe for all versions of Perl as it leaves all code execution to the eval in the current scope, avoiding closures altogether. Requirements: · Perl


Exception::Class::TryCatch Related Software