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: 14802
Status: resolved
Priority: 0/
Queue: Exception-Class

People
Owner: Nobody in particular
Requestors: jdhedden [...] 1979.usna.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.21
Fixed in: 1.22



Subject: ->caught() missing as an Exception::Class::Base method
Currently, only Exception::Class implements a ->caught() method. It uses the syntax: Exception::Class->caught('Some::Exception::Class') There should also be a ->caught() method that is inheritable from Exception::Class::Base so that any of its subclasses can use the following syntax: Some::Exception::Class->caught() This is the syntax that is presented in Damian Conway's Perl book "Best Practices". The above can be accomplished by adding either of the following to package Exception::Class::Base: sub caught { my $class = shift; my $e = $@; return unless blessed($e) && $e->isa($class); return $e; } --- OR --- sub caught { return Exception::Class->caught(shift); }
[JDHEDDEN - Wed Sep 28 16:47:44 2005]: Show quoted text
> Currently, only Exception::Class implements a ->caught() method. It > uses the syntax: > Exception::Class->caught('Some::Exception::Class') > > There should also be a ->caught() method that is inheritable from > Exception::Class::Base so that any of its subclasses can use the > following syntax: > Some::Exception::Class->caught() > > This is the syntax that is presented in Damian Conway's Perl book > "Best Practices". > > The above can be accomplished by adding either of the following to > package Exception::Class::Base: > > sub caught > { > my $class = shift; > my $e = $@; > > return unless blessed($e) && $e->isa($class); > return $e; > } > > --- OR --- > > sub caught > { > return Exception::Class->caught(shift); > }
Hmm, that's not what I remember him suggesting before the book came out, but you are right that's what he documented. I actually prefer the other way since I think it reads better as "if caught(Foo)" but I'll add this for the sake of the book.