use Exception::Class ( 'MyException', ^^^^^^^^^^^ #1 'AnotherException' => { isa => 'MyException' }, ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ #2 & 3 'YetAnotherException' => { ^^^^^^^^^^^^^^^^^^^^ #4 isa => 'AnotherException', ^^^^^^^^^^^^^^^^ #5 description => 'These exceptions are related to IPC' }, 'ExceptionWithFields' => { ^^^^^^^^^^^^^^^^^^^ #6 isa => 'YetAnotherException', #7 ^^^^^^^^^^^^^^^^^^^ fields => [ 'grandiosity', 'quixotic' ], alias => 'throw_fields', }, ); #### eval{ die { a=>b=>c=>d=>}; } or print %{ $@ };; c d a b #### # catch if ( $e = Exception::Class->caught('MyException') ) { warn $e->error, "\n", $e->trace->as_string, "\n"; warn join ' ', $e->euid, $e->egid, $e->uid, $e->gid, $e->pid, $e->time; exit; } elsif ( $e = Exception::Class->caught('ExceptionWithFields') ) { $e->quixotic ? do_something_wacky() : do_something_sane(); } else { $e = Exception::Class->caught(); ref $e ? $e->rethrow : die $e; }