Untested, but peeking at the source code, it appears that SQL::Parser has two settings for error messages which can be set independently...

my $parser = SQL::Parser->new('AnyData', { PrintError => 0, # off RaiseError => 1, # on });

If both are false, then when SQL::Parser hits an error it will plough on without notifying you (though you can call $parser->errstr to obtain the most recent error message.

If PrintError is switched on (and it is on by default), then it will warn you when an error occurs. This can be caught using $SIG{__WARN__}.

If RaiseError is switched on (but it is off by default), then it will die when an error occurs. This can be caught using $SIG{__DIE__} or eval or something like Try::Tiny.

If both are switched on, it will warn and die when an error message occurs. This is why you're getting a double error message:

Incomplete SET clause! at ./post_audit.pl line 173 Incomplete SET clause! at ./post_audit.pl line 173

This is also why your eval isn't appearing to work. It's catching the die, but allowing the warnto pass through, because although you've switched RaiseError on, you haven't switched PrintError off.

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

In reply to Re: How to catch SQL::Parser errors in Perl by tobyink
in thread How to catch SQL::Parser errors in Perl by som.nitk

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.