OpenPlugin::Exception

Base class for exceptions in OpenPlugin
Download

OpenPlugin::Exception Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Eric Andreychek and Chris Winters
  • Publisher web site:
  • http://search.cpan.org/~eric/OpenPlugin-0.11/OpenPlugin/Datasource/Template.pm

OpenPlugin::Exception Tags


OpenPlugin::Exception Description

Base class for exceptions in OpenPlugin OpenPlugin::Exception is a base Perl class for exceptions in OpenPlugin.SYNOPSIS # Throw an exception $OP->exception->throw("An exception has occurred"); # Throw an exception, and log the message using the Log Plugin $OP->exception->log_throw("An exception has occurred"); # Catch an exception, get more info on it with creation_location() eval { $OP->session->save( $session ) }; if ( $@ ) { print "Error: $@", $@->creation_location, " "; } # Or, get a stack trace eval { $OP->session->save( $session ) }; 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 = $OP->exception->get_stack; print "Errors found: "; foreach my $e ( @errors ) { print "ERROR: ", $e->creation_location, " "; } # As a developer of a module which uses OpenPlugin my $rv = eval { $dbh->do( $sql ) }; if ( $@ ) { $@->throw( "There was an error! $@" ); } # Throw an exception that subclasses OpenPlugin::Exception with extra # fields (Assumes creation of OpenPlugin::Exception::DBI) my $rv = eval { $dbh->do( $sql ) }; if ( $@ ) { $OP->exception('DBI')->throw( $@, { sql => $sql, action => 'do' } ); } # Catch an exception, do some cleanup then rethrow it my $rv = eval { $OP->session->fetch( $session_id ) }; if ( $@ ) { my $exception = $@; $OP->datasource->disconnect('Database_DataSource'); $OP->datasource->disconnect('LDAP_DataSource'); $OP->exception->throw( $exception ); }This class is the base for all exceptions in OpenPlugin. 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. Requirements: · Perl


OpenPlugin::Exception Related Software