Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to catch SQL::Parser errors in Perl

by tobyink (Canon)
on May 15, 2013 at 12:24 UTC ( #1033671=note: print w/replies, xml ) Need Help??


in reply to How to catch SQL::Parser errors in Perl

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

Replies are listed 'Best First'.
Re^2: How to catch SQL::Parser errors in Perl
by som.nitk (Novice) on May 16, 2013 at 07:37 UTC
    Bingo! Thanks !

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1033671]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2022-01-20 02:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (56 votes). Check out past polls.

    Notices?