[cgiapp] catching exceptions
green at umdnj.edu
Fri Jan 6 16:02:12 EST 2012
On 1/6/2012 3:52 PM, Rhesa Rozendaal wrote:
> On 01/06/2012 09:45 PM, Cliff Green wrote:
>> I have an application using CGI::Application, DBIx::Class, and
>> CGI::Application::Plugin::DBIC::Schema and if all's well, it hums along
>> nicely (okay, it could do some things better).
>> But, if one there's a problem connecting to one of the databases (e.g.,
>> network problems, or if the db is down), I'd like to be able to catch
>> the exception and advise the user in the app; as it is now, the app
>> fails and the user gets a Apache error notice.
>> I've been trying to use DBIx::Class's exception_action method, and have
>> not been successful (under CGI::Application).
>> I would be grateful for some clues in making this right.
> see https://metacpan.org/module/CGI::Application#error_mode- for one way
> to handle exceptions in your run modes.
Thanks, I do use error_mode, returning $self->error if $@ has been
raised from an LDAP failure, or if a function doesn't return a hash, but
it looks like DBIx::Class is dying and not giving me the chance to trap
the exception. The frustrating thing is that in a command-line script
(no CAP::DBIC:Schema hiding the naughty bits), there's no problem
trapping the exception right after attempting to connect to the db.
More information about the cgiapp