[cgiapp] catching exceptions
Green, Cliff
green at umdnj.edu
Sat Jan 7 15:10:43 EST 2012
On 1/6/2012 5:27 PM, Joshua Miller wrote:
> 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.
Yeah, DBIx::Class has default behavior (including for exceptions) which
I hope I don't have to work around - I'd rather not cause more problems
by fixing this corner case.
I may have to either dump CAP::DBIC::Schema or revise some of my
runmodes to better capture the exception.
Thanks!
c
More information about the cgiapp
mailing list