Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Exception-Class CPAN distribution.

Report information
The Basics
Id: 65171
Status: resolved
Priority: 0/
Queue: Exception-Class

People
Owner: Nobody in particular
Requestors: nigel [...] mcnie.name
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.32
Fixed in: 1.37



Subject: Example code in synopsis is broken
The example code in the synopsis is broken, because the sample catch block will always die. # 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- Show quoted text
>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; # <<<< HERE } If the eval doesn't die, $@ is ''. In the else block, this isn't checked for - the die statement will run if $e isn't a reference. It's a bit confusing if you're trying to get a sense for how the module works by using the synopsis as a test :) I ended up doing this in my code: my $e = Exception::Class->caught(); ref $e ? $e->rethrow : $e ? die $e : undef; I'm sure there's a nicer way. Cheers, Nigel