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

Re: Fatal/autodie exception hierarchies for Perl 5

Thread Previous | Thread Next
From:
Joshua ben Jore
Date:
June 8, 2008 12:34
Subject:
Re: Fatal/autodie exception hierarchies for Perl 5
Message ID:
dc5c751d0806081234u559592e6g82d82e4b650ecfa6@mail.gmail.com
On Sun, Jun 1, 2008 at 7:31 PM, Paul Fenwick <pjf@perltraining.com.au> wrote:
> Currently, when testing exceptions from autodie, we can use:
>
>        given ($@) {
>                when (undef)   { say "No errors here" }
>                when ('open')  { say "Open died" }
>                when (':file') { say "Some sort of file error" }
>                when (':io')   { say "Some other error" }
>                when (':CORE') { say "Some other CORE error" }
>                when (':USER') { say "A non-CORE error" }
>                when (':all')  { say "Any autodie exception at all." }
>                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.

    given( my $_ = $@ ) {
        ...
        default { say '$@ committed suicide' }
    }

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.

Josh

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