develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Fatal/autodie exception hierarchies for Perl 5

Thread Previous | Thread Next
From:
Paul Fenwick
Date:
June 8, 2008 22:18
Subject:
Re: Fatal/autodie exception hierarchies for Perl 5
Message ID:
484CBD2C.3050608@perltraining.com.au
G'day Josh / p5p / p6l,


>>        given ($@) {
>>		  # [snip]
>>                default        { say "Not an autodie exception." }
>>        }
> 
> If you're going to write that into some documentation, I wish you'd
> make default say that it's exception suicide.

The documentation clearly needs to make clear what that default means,
because it's certainly not exception suicide.  The exceptions thrown from
autodie bind smart-match (used in given/when) to a 'does/has_role' style
check.  The ':all' test (which may change its name) checks against a
meta-role shared by all autodie exceptions.  If something doesn't match
that, then it wasn't an exception from autodie.  It could have been an
exception from something else, or even a plain string exception.

> Semi-recently at work I found that a few buggy exception objects in
> the global $@ were clearing themselves out of $@ as a side effect of
> examining them for truth. It's quite annoying and mysterious when it
> happens.

Yes, I've seen this sort of behaviour too, and I'm being particularly
mindful to make sure it doesn't happen with the code in autodie.  I've
marked myself down a TODO item to make sure there's a big barrage of tests
to ensure that $@ still contains what we expect at the end of each exception
handling block.

Cheerio,

	Paul

-- 
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About