Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Try::Tiny catch block with $_ eq ''

by vsespb (Chaplain)
on May 16, 2013 at 21:29 UTC ( #1033911=note: print w/replies, xml ) Need Help??

in reply to Try::Tiny catch block with $_ eq ''

I don't know answer to your question, but you can try use perl 'sigtrap' module to get stacktrace, and possibly temporary replace try/catch/$_ with 'unless defined eval { }'/$@ , to debug your code.
UPD: For example
unless (defined eval { $self->_run($self, $row_id, $subject); 1 }) { $logger->error("run($row_id): $@\n") }; $self->_clear_subject;
this way you'll check if that is the problem with "my $_" or no.

Replies are listed 'Best First'.
Re^2: Try::Tiny catch block with $_ eq ''
by dd-b (Monk) on May 16, 2013 at 22:39 UTC

    I'm using Try::Tiny because they claim it's hard to really use eval correctly to do this, but I could switch back and hope I don't hit their problem cases, at least as a test. We shall see. I've been putting eleventy-dozen $logger->trace("point 17"); statements through the code it comes out of unexpectedly to narrow down where it is. Setting up the database for a test run and then analyzing the log is not as simple as I could hope it was (though far better than my test setup procedure two weeks ago :-) ).

      I think it's hard when there are nested evals. Otherwise it's pretty simple, if you read the docs carefully.

        That's not the main eval gotcha that Try::Tiny seeks to solve. Amongst the things mentioned in Try::Tiny's documentation are:

        • It is possible to throw an exception which is considered false in a boolean context, thus breaking if ($@). Try::Tiny isn't fooled by that.
        • If a DESTROY method calls eval then an object used within your eval could potentially clobber $@. Try::Tiny creates a copy of $@ that is safe, and passes it as a parameter to the catch block.

        These errors are fairly rare in practice, but extremely difficult to figure out when they do happen. People who have been burned by them in the past tend to appreciate Try::Tiny quite a lot.

        package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033911]
and cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2018-06-22 21:34 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.