The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

perfSONAR_PS::Error_compat - A module that provides a transition between a full on exceptions framework for perfSONAR PS and having each service specify explicitly the eventType and description.

DESCRIPTION

This module provides a simple method for throwing exceptions that look similar to how eventType/description messages used to be propogated.

SYNOPSIS

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

### script.pl ###

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

  $dbh = &openDB();

}
catch perfSONAR_PS::Error_compat with {

  # print the contents of the error object (the string)
  print "An error occur: ".$@->eventType."/".$@->errorMessage."\n";

}
otherwise {

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

}
finally {

  print "Done!\n"'

}; 

# don't forget the trailing ';'

SEE ALSO

perfSONAR_PS::Services::Base, perfSONAR_PS::Services::MA::General, perfSONAR_PS::Common, perfSONAR_PS::Messages, perfSONAR_PS::Transport, perfSONAR_PS::Client::Status::MA, perfSONAR_PS::Client::Topology::MA

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

$Id:$

AUTHOR

Aaron Brown, aaron@internet2.edu

LICENSE

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

Copyright (c) 2004-2008, Internet2 and the University of Delaware

All rights reserved.