jbenezech has asked for the wisdom of the Perl Monks concerning the following question:
package DB::DBException; use base qw(Error); sub new { my ($self, $msg) = @_; my @args = (); local $Error::Depth = $Error::Depth + 1; local $Error::Debug = 1; # Enables storing of stacktrace $self->SUPER::new(-text => $msg, @args); return $self; }
use strict; use warnings; use Error qw(:try); use DB::DBException; try { throw DB::DBException("Connect exception"); print "OK\n"; } catch DB::DBException with { print "DBException"; } catch Error with { print "Error"; }; print "finished";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error.pm and custom Exception
by ELISHEVA (Prior) on Feb 24, 2009 at 11:11 UTC | |
|
Re: Error.pm and custom Exception
by fmerges (Chaplain) on Feb 24, 2009 at 11:57 UTC | |
|
Re: Error.pm and custom Exception
by Anonymous Monk on Feb 24, 2009 at 12:47 UTC | |
by jbenezech (Acolyte) on Feb 25, 2009 at 03:10 UTC |