perfSONAR_PS::Error - A module that provides the exceptions framework for perfSONAR PS


perfSONAR_PS-Base documentation  | view source Contained in the perfSONAR_PS-Base distribution.

Index


NAME

Top

perfSONAR_PS::Error - A module that provides the exceptions framework for perfSONAR PS

DESCRIPTION

Top

This module provides the base object for all exception types that will be presented.

SYNOPSIS

Top

  # first define the errors somewhere
  package Some::Error;
  use base "Error::Simple";
  1;




  use Some::Error;

  # you MUST import this, otherwise the try/catch blocks will fail
  use Error qw(:try);  

  # if an error occurs, perfSONAR_PS objects should throw an error eg
  sub openDB {
    my $handle = undef;
    $handle = DBI->connect( ... )
  	  or throw Some::Error( "Could not connect to database: " . $DBI::errstr . "\n" );
  	return $handle;
  }




  ### script.pl ###

  # in the calling code
  my $dbh = undef;
  try {

    $dbh = &openDB();

  }
  catch Some::Error with {

    # print the contents of the error object (the string)
    print "An error occurred $@\n";

  }
  otherwise {

    # some other error occured!
    print "Some unknown error occurred! $@\n";

  }
  finally {

    print "Done!\n"'

  }; 

  # don't forget the trailing ';'




toEventType

returns the perfsonar event type for this exception as a string, ensure that you throw the appropriate inheritied exception object for automatic eventType creation.

errorMessage

returns the error message itself (also the same as casting the object as a string)

SEE ALSO

Top

Exporter, Error::Simple

To join the 'perfSONAR-PS' mailing list, please visit:

  https://mail.internet2.edu/wws/info/i2-perfsonar

The perfSONAR-PS subversion repository is located at:

  https://svn.internet2.edu/svn/perfSONAR-PS

Questions and comments can be directed to the author, or the mailing list.

VERSION

Top

$Id$

AUTHOR

Top

Yee-Ting Li <ytl@slac.stanford.edu>

LICENSE

Top

You should have received a copy of the Internet2 Intellectual Property Framework along with this software. If not, see <http://www.internet2.edu/membership/ip.html>

COPYRIGHT

Top


perfSONAR_PS-Base documentation  | view source Contained in the perfSONAR_PS-Base distribution.