SPOPS::Exception

Base class for exceptions in SPOPS
Download

SPOPS::Exception Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Chris Winters
  • Publisher web site:
  • http://search.cpan.org/~cwinters/SPOPS-0.87/SPOPS/SQLInterface.pm

SPOPS::Exception Tags


SPOPS::Exception Description

Base class for exceptions in SPOPS SPOPS::Exception is a Perl class for exceptions in SPOPS.SYNOPSIS # As a user use SPOPS::Exception; eval { $user->save }; if ( $@ ) { print "Error: $@", "Stack trace: ", $@->trace->as_string, " "; } # Get all exceptions (including from subclasses that don't override # throw()) since the stack was last cleared my @errors = SPOPS::Exception->get_stack; print "Errors found: "; foreach my $e ( @errors ) { print "ERROR: ", $e->message, " "; } # As a developer use SPOPS::Exception; my $rv = eval { $dbh->do( $sql ) }; if ( $@ ) { SPOPS::Exception->throw( $@ ); } # Use the shortcut use SPOPS::Exception qw( spops_error ); my $rv = eval { $dbh->do( $sql ) }; spops_error( $@ ) if ( $@ ); # Throw an exception that subclasses SPOPS::Exception with extra # fields my $rv = eval { $dbh->do( $sql ) }; if ( $@ ) { SPOPS::Exception::DBI->throw( $@, { sql => $sql, action => 'do' } ); } # Throw an exception with a longer message and parameters SPOPS::Exception->throw( "This is a very very very very ", "very long message, even though it ", "doesn't say too much.", { action => 'blah' } ); # Catch an exception, do some cleanup then rethrow it my $rv = eval { $object->important_spops_operation }; if ( $@ ) { my $exception = $@; close_this_resource(); close_that_resource(); SPOPS::Exception->throw( $exception ); }This class is the base for all exceptions in SPOPS. An exception is generally used to indicate some sort of error condition rather than a situation that might normally be encountered. For instance, you would not throw an exception if you tried to fetch() a record not in a datastore. But you would throw an exception if the query failed because the database schema was changed and the SQL statement referred to removed fields.This module replaces SPOPS::Error and the error handling it used. There is a backwards compatible function in place so that the variables get set in SPOPS::Error, but this is not permanent. If you use these you should modify your code ASAP.You can easily create new classes of exceptions if you like, see SUBCLASSING below. Requirements: · Perl


SPOPS::Exception Related Software