dd-b has asked for the wisdom of the Perl Monks concerning the following question:
I'm having trouble with ending up in my catch block without any indication of why. Code blocks like:
try { $self->_run($self, $row_id, $subject) } catch { $logger->error("run($row_id): $_\n") }; $self->_clear_subject;
(that $logger is from Log::Log4perl).
Something happens down in $self->_run() and I end up in the catch block, but with no indication of why.
So, what are the things that count as "errors" for Try::Tiny? The docs just say "error", which doesn't mean anything terribly precise. The obvious case I know about is die calls. I don't have any die calls with null strings as their arguments. (What I end up with in the catch block is a string that Data::Dumper prints as ''. I know that's not impossible; the error put in $_ may not be "true". But I don't have a die statement with a null string arg, and I wouldn't expect DBIC or any standard module to have a die call with a null string arg.)
I'm using DBIC database stuff in there, and I know it throws errors (in fact that's the point of this whole setup, to catch any errors it throws), but I don't expect it to throw null string errors; does it sometimes?
I may also be slightly wrong about how far my code got; I've run into at least one case (that I can't reproduce in a simple environment) where it seemed that $logger->trace("String with undefined $variable substituted"); would log nothing ($variable is undef; I'd expect it to log "String with undefined substituted" and give a warning on stderr about the undef, and that's what a simple program that does only that produces). Other trace level calls through the same $logger in the same module are logged. As I say, I can't reproduce this in a simple case, it may be another example of my getting confused.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Try::Tiny catch block with $_ eq ''
by tobyink (Canon) on May 16, 2013 at 21:39 UTC | |
by dd-b (Pilgrim) on May 16, 2013 at 22:37 UTC | |
|
Re: Try::Tiny catch block with $_ eq ''
by vsespb (Chaplain) on May 16, 2013 at 21:29 UTC | |
by dd-b (Pilgrim) on May 16, 2013 at 22:39 UTC | |
by vsespb (Chaplain) on May 16, 2013 at 22:45 UTC | |
by tobyink (Canon) on May 17, 2013 at 12:26 UTC | |
by vsespb (Chaplain) on May 17, 2013 at 12:38 UTC | |
|
Re: Try::Tiny catch block with $_ eq ''
by locked_user sundialsvc4 (Abbot) on May 17, 2013 at 13:32 UTC |