in reply to How do I override the error display of a CGI::Application
Quoted from the CGI::Application documentation:
THE RUN-MODE OF LAST RESORT: "AUTOLOAD"
If CGI::Application is asked to go to a run-mode which doesn't exist
it will usually croak() with errors. If this is not your desired
behavior, it is possible to catch this exception by implementing a
run-mode with the reserved name "AUTOLOAD":
$self->run_modes(
"AUTOLOAD" => \&catch_my_exception
);
Before CGI::Application called croak() it will check for the
existance of a run-mode called "AUTOLOAD". If specified, this
run-mode will in involked just like a regular run-mode, with one
exception: It will receive, as an argument, the name of the run-mode
which involked it:
sub catch_my_exception {
my $self = shift;
my $intended_runmode = shift;
my $output = "Looking for '$intended_runmode', but found 'AUTOLOAD' instead";
return $output;
}
This functionality could be used for a simple human-readable error
screen, or for more sophisticated application behaviors.
|
|---|