Bugzilla – Bug 6837
Use Error.pm for error handling
Last modified: 2009-11-01 12:52:56
You need to log in before you can comment on or make changes to this bug.
Use Error.pm to clean up error handling. http://search.cpan.org/dist/Error/ http://www.perl.com/pub/a/2002/11/14/exception.html (not slightly out of date) For example: #!/usr/bin/env perl use Error qw(:try); use myException; try { test("exceptional world"); } catch Error with { my $ex = shift; print "Exception: " . $ex->text() . "\n"; }; #Error::flush(); print "Done.\n"; exit(0); sub test { my $name = shift; print "Hello $name.\n"; throw myException("Bad code."); } ---myException.pm-- package myException; use base qw(Error); use overload ('""' => 'stringify'); sub new { my $self = shift; my $text = "" . shift; my @args = (); local $Error::Depth = $Error::Depth + 1; local $Error::Debug = 1; # Enables storing of stacktrace $self->SUPER::new(-text => $text, @args); } 1;
This is done on HEAD.