On Mon, 20 May 2002, Mark Fowler wrote:

> On Mon, 20 May 2002, Matt Sergeant wrote:
>
> > if ($@ && $@->isa('Exception::DB')) {
> >    debug "Exception: $@";
> >    $um->dbh->rollback;
> > }
> >
> > (note: if you expect all exceptions to be references like this, you had
> > better have a $SIG{__DIE__} handler installed to bless non-blessed
> > exceptions before re-throwing them
>
> Can't you just use UNIVERSAL's ISA method directly?
>
>    if (UNIVERSAL::isa($@,'Exception::DB')) {
>
> This of course might fail if you got the string "Exception::DB" or
> likewise back as an error message.
>
> Alternativly, check if it's blessed
>
>    use Scalar::Util qw(blessed);
>
>    if (blessed($@) && $@->isa('Exception::DB')) {

Yeah, I know all the tricks. Ultimately it's a matter of how ugly you want
your code to get, and how many external modules you want to rely on (I
believe Scalar::Util is going to be part of 5.8 though).

-- 
<!-- Matt -->
<:->Get a smart net</:->

Reply via email to