in reply to CGI::Application cgi_prerun exception handling

I've never used CGI::Application before, so this is my first take on it:
package My::App; use strict; use warnings; use base qw(CGI::Application); use CGI::Application::Plugin::DebugMessage; $_ = My::App->new; $_->debug('Abandon Ship!'); $_->run; sub cgiapp_init { my $self = shift; $self->mode_param('rm'); $self->run_modes([ 'login', 'AUTOLOAD' ]); } sub cgiapp_prerun { my ( $this, $rm ) = @_; eval { do { (); } }; if ($@) { $_->debug('Abandon Ship!'); } }

Replies are listed 'Best First'.
Re^2: CGI::Application cgi_prerun exception handling
by morgon (Priest) on Jan 02, 2011 at 06:47 UTC
    Thanks for your reply but unfortunately I don't understand your point.

    Maybe I did not make clear what my problem is.

    I have runmodes that may throw exceptions and a generic pre-run that also potentially throws exceptions.

    Whenever an exception occurs I want it to be handled in one central location (the error-runmode) where I will then generate different responses for the client, depending on the exception thrown (I deal with an application that generates XML for machine-clients).

    The question is know how to pass an exception that occurs in the pre-run on to the error-runmode in an elegant way.

    Sorry if you provided an answer to that in your posting that I failed to understand.