Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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.)

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031009]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-02-22 19:35 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (298 votes). Check out past polls.