use Exception::Class ( 'MyException', 'Commands' => { isa => 'MyException' }, 'Timeout' => { isa => 'Commands', description => 'These exceptions are resulted from running the metrics commands' }, 'DBError' => { isa => 'MyException', description => 'DB returned error' } ); ThrowMyException(); sub ThrowMyException() { eval{MyException::Commands::Timeout->throw(error=>"This is error due to timeout");}; my $err; if($err=Exception::Class->caught('MyException::Commands::Timeout')){ #print Dumper($err); #print "err is of type ".ref($err); die $err->{"description"}.": ".$err->{"error"}; } elsif ( $err = Exception::Class->caught("MetricsException") ) { #print Dumper($err); die $err->error; } }