[cgiapp] Getting error_mode to catch die in cgiapp_prerun

Lyle webmaster at cosmicperl.com
Fri Jan 16 13:54:08 EST 2009


Hi All,
  I've noticed that if my app dies in cgiapp_prerun then my error mode 
defined in setup isn't called.

Is there a reason for this? Is there a way to get error_mode to catch 
errors in cgiapp_prerun?


Sample module:-

package Test;

BEGIN {
    use FindBin qw ($RealBin $RealScript);
    use lib $FindBin::RealBin;
    chdir $RealBin;
    if ( $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ) {
        open STDERR, '> iisError.log' || die "Can't write to 
$RealBin/issError.log: $!\n";
        binmode STDERR;
        #close STDERR;
    }#if
}#BEGIN


use base 'CGI::Application';
use strict;

sub setup {
    my $self = shift;
    $self->start_mode('test');
    $self->error_mode( 'error' );
    $self->run_modes(
        'test' => 'test',
    );
}#sub

sub teardown {
    my $self = shift;
}#sub

sub cgiapp_prerun {
    my $self = shift;
    die( "Death message" ); ## 500 error
}#sub


sub test {
    my $self = shift;
#    die( "Death message" ); ## works
    return "Test";
}#sub

sub error {
    my $self = shift;
    return "Error mode ran @_";
}


1;



More information about the cgiapp mailing list