Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Untested, but peeking at the source code, it appears that SQL::Parser has two settings for error messages which can be set independently...
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:
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
|
|