Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Die inside Try::Tiny blocks

by dd-b (Monk)
on Apr 27, 2013 at 19:47 UTC ( #1031009=note: print w/ replies, xml ) Need Help??


in reply to Re: Die inside Try::Tiny blocks
in thread Die inside Try::Tiny blocks

Yes, I guess those statements about error handling do imply the behavior I'm seeing. They don't immediately make me think of that behavior, though. I'll try to figure out of I can make it clearer and try a doc patch if so.

Since Try::Tiny says it exists to avoid the mistakes people make using eval for this kind of thing it does seem like using it again inside the the finally block as needed is what the authors had in mind...should be amusing.

(I only had one place in the code I'm actually working on where I'd messed up use of try blocks, but it was good to run through and check all the ones I'd added to be sure.)


Comment on Re^2: Die inside Try::Tiny blocks
Re^3: Die inside Try::Tiny blocks
by chromatic (Archbishop) on Apr 27, 2013 at 21:50 UTC

    You're probably doing something far more complicated than you ought to if your finally block can throw an exception. I wouldn't do anything more than logging an error or setting a flag to restart a computation.

      So finally blocks aren't in fact good ways to make sure cleanup gets performed? That's kind of advertised as their main purpose -- but DBIx, for example, reports most errors with exceptions (and I like that style in general).
        So finally blocks aren't in fact good ways to make sure cleanup gets performed?

        They are, but you're talking about nesting code which may throw exceptions in the finally blocks of exception handlers. How are you going to handle those exceptions? Do they have their own finally blocks? This gets complicated pretty fast.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031009]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-09-16 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (0 votes), past polls