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.


In reply to Try::Tiny catch block with $_ eq '' by dd-b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.