sub cgiapp_prerun {
my $this = shift;
my $rm = shift;
eval {
...
};
if($@) {
$this->stash->{exception} = "Error in prerun: $@";
$this->prerun_mode("error");
}
}
sub error { # error-runmode
my $this = shift;
my $exception = shift ||
$this->stash->{exception} ||
"default error message goes here";
...
}
####
$this->error("danger! red alert!");
####
# check 'name' entry
unless ($name) {
$this->stash->{exception} .= "bad name\n";
}
# check 'address' entry
unless ($address) {
$this->stash->{exception} .= "bad address\n";
}
# check 'phone' entry
unless ($phone) {
$this->stash->{exception} .= "bad phone\n";
}
return $this->error( $this->stash->{exception} )
if $this->stash->{exception};
...