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);
}