in reply to How do I override the error display of a CGI::Application

I have just started using CGI::Application (and am loving it). And my best guess would be to use the AUTOLOAD run mode. I don't know if this is the correct way of solving this, though I think it is.

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.

  • Comment on Re: How do I override the error display of a CGI::Application