|
Packit |
2ffe24 |
NAME
|
|
Packit |
2ffe24 |
Error - Error/exception handling in an OO-ish way
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
DESCRIPTION
|
|
Packit |
2ffe24 |
The Error package provides two interfaces. Firstly Error provides
|
|
Packit |
2ffe24 |
a procedural interface to exception handling. Secondly Error is a
|
|
Packit |
2ffe24 |
base class for errors/exceptions that can either be thrown, for
|
|
Packit |
2ffe24 |
subsequent catch, or can simply be recorded.
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Errors in the class Error should not be thrown directly, but the
|
|
Packit |
2ffe24 |
user should throw errors from a sub-class of Error
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
SYNOPSIS
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
use Error qw(:try);
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
throw Error::Simple( "A simple error");
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
sub xyz {
|
|
Packit |
2ffe24 |
...
|
|
Packit |
2ffe24 |
record Error::Simple("A simple error")
|
|
Packit |
2ffe24 |
and return;
|
|
Packit |
2ffe24 |
}
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
unlink($file) or throw Error::Simple("$file: $!",$!);
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
try {
|
|
Packit |
2ffe24 |
do_some_stuff();
|
|
Packit |
2ffe24 |
die "error!" if $condition;
|
|
Packit |
2ffe24 |
throw Error::Simple -text => "Oops!" if $other_condition;
|
|
Packit |
2ffe24 |
}
|
|
Packit |
2ffe24 |
catch Error::IO with {
|
|
Packit |
2ffe24 |
my $E = shift;
|
|
Packit |
2ffe24 |
print STDERR "File ", $E->{'-file'}, " had a problem\n";
|
|
Packit |
2ffe24 |
}
|
|
Packit |
2ffe24 |
except {
|
|
Packit |
2ffe24 |
my $E = shift;
|
|
Packit |
2ffe24 |
my $general_handler=sub {send_message $E->{-description}};
|
|
Packit |
2ffe24 |
return {
|
|
Packit |
2ffe24 |
UserException1 => $general_handler,
|
|
Packit |
2ffe24 |
UserException2 => $general_handler
|
|
Packit |
2ffe24 |
};
|
|
Packit |
2ffe24 |
}
|
|
Packit |
2ffe24 |
otherwise {
|
|
Packit |
2ffe24 |
print STDERR "Well I don't know what to say\n";
|
|
Packit |
2ffe24 |
}
|
|
Packit |
2ffe24 |
finally {
|
|
Packit |
2ffe24 |
close_the_garage_door_already(); # Should be reliable
|
|
Packit |
2ffe24 |
}; # Don't forget the trailing ; or you might be surprised
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
AUTHORS
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Graham Barr <gbarr@pobox.com>
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
The code that inspired me to write this was originally written by
|
|
Packit |
2ffe24 |
Peter Seibel <peter@weblogic.com> and adapted by Jesse Glick
|
|
Packit |
2ffe24 |
<jglick@sig.bsh.com>.
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
MAINTAINER
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Arun Kumar U <u_arunkumar@yahoo.com>
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
=====================
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
HOW TO INSTALL IT ?
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
To install this module, cd to the directory that contains this README
|
|
Packit |
2ffe24 |
file and type the following:
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
perl Makefile.PL
|
|
Packit |
2ffe24 |
make test
|
|
Packit |
2ffe24 |
make install
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
To install this module into a specific directory, do:
|
|
Packit |
2ffe24 |
perl Makefile.PL PREFIX=/name/of/the/directory
|
|
Packit |
2ffe24 |
...the rest is the same...
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Please also read the perlmodinstall man page, if available.
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Share and Enjoy !!
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
Arun Kumar U
|
|
Packit |
2ffe24 |
<u_arunkumar@yahoo.com>
|
|
Packit |
2ffe24 |
|
|
Packit |
2ffe24 |
-------------------------------------------------------------------------------
|
|
Packit |
2ffe24 |
Only wimps use tape backup: *real* men just upload their important
|
|
Packit |
2ffe24 |
stuff on ftp, and let the rest of the world mirror it.
|
|
Packit |
2ffe24 |
- Linus Torvalds
|
|
Packit |
2ffe24 |
-------------------------------------------------------------------------------
|
|
Packit |
2ffe24 |
|