[cgiapp] catching exceptions
Joshua Miller
unrtst at gmail.com
Fri Jan 6 17:27:27 EST 2012
On Fri, Jan 6, 2012 at 4:02 PM, Cliff Green <green at umdnj.edu> wrote:
> ...
> it looks like DBIx::Class is dying and not giving me the chance to trap
> the exception. ...
It may have an option to not die on error (DBI has one), and you could then
test for and manually catch exceptions. However, the (I'm assuming) default
behavior is a good thing, you just need to trap it. Here's one way to do it:
my $var;
eval {
$var = $dbixclass_obj->dowhatever( ... );
1;
} or do {
# handle exception
my $error = $@;
# do whatever you want with the error.
# the $error var holder is so that, if you make another call here,
# it's results won't flush the $@ variable.
};
There's loads of exception handling modules out there that aid in this
stuff or make throwing exceptions better/easier/etc, but that's the basics.
If your'e already doing something like that and it's not getting caught or
something, please provide sample code or more details.
--
Josh I.
More information about the cgiapp
mailing list