in reply to switch question
Maybe your exception classes should implement errorcode()?
Cheers Christophupdate: example addedBEGIN{ sub Exception::Class::Base::errorcode{ my %def = shift->_defaults; return $def{errorcode} ; } sub Exception::Class::Base::_defaults{ return (errorcode => 3); } } use Exception::Class ( 'MyException' => {defaults => {errorcode => 2} }, 'AnotherException' => { isa => 'MyException' }, 'YetAnotherException' => { isa => 'AnotherException', defaults => {errorcode => 5}, }, ); eval { YetAnotherException->throw( error => 'I feel funny.' ) }; my $e; if ( $e = Exception::Class->caught()){ warn $e->error, "\n"; warn $e->errorcode , "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: switch question
by morgon (Priest) on Jan 06, 2011 at 23:01 UTC |