/ module /

Filename Size Date modified Message
495 B
7.8 KB
737 B
302 B
2.4 KB
    Error - Error/exception handling in an OO-ish way

    The Error package provides two interfaces. Firstly Error provides
    a procedural interface to exception handling. Secondly Error is a
    base class for errors/exceptions that can either be thrown, for
    subsequent catch, or can simply be recorded.

    Errors in the class Error should not be thrown directly, but the
    user should throw errors from a sub-class of Error


    use Error qw(:try);

    throw Error::Simple( "A simple error");

    sub xyz {
	record Error::Simple("A simple error")
	    and return;
    unlink($file) or throw Error::Simple("$file: $!",$!);

    try {
	die "error!" if $condition;
	throw Error::Simple -text => "Oops!" if $other_condition;
    catch Error::IO with {
	my $E = shift;
	print STDERR "File ", $E->{'-file'}, " had a problem\n";
    except {
	my $E = shift;
	my $general_handler=sub {send_message $E->{-description}};
	return {
	    UserException1 => $general_handler,
	    UserException2 => $general_handler
    otherwise {
	print STDERR "Well I don't know what to say\n";
    finally {
	close_the_garage_door_already(); # Should be reliable
    }; # Don't forget the trailing ; or you might be surprised


    Graham Barr <>

    The code that inspired me to write this was originally written by
    Peter Seibel <> and adapted by Jesse Glick


    Arun Kumar U <>



To install this module, cd to the directory that contains this README
file and type the following:

    perl Makefile.PL
    make test
    make install

To install this module into a specific directory, do:
perl Makefile.PL PREFIX=/name/of/the/directory
...the rest is the same...

Please also read the perlmodinstall man page, if available.

Share and Enjoy !!

Arun Kumar U 

    Only wimps use tape backup: *real* men just upload their important 
    stuff on ftp, and let the rest of the world mirror it.
                                                           - Linus Torvalds

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.