Mark Stosberg wrote:
A call to my error routine might look like this:
my $q = $self->query; my $id = $q->param('id');
# check that ID is present and a digit or throw an error
($id =~ m/^\d+$/) or return $self->error(
title => 'Insufficient Information',
msg => 'Insufficient information was recieved to process
your request.' );
The actual error() routine is as simple:
sub error {
my $self = shift;
my %args = @_;
my $tmpl = $self->load_tmpl('error.html');
$tmpl->param(%args);
return $tmpl->output;
}
##########
That is usually how I handle errors as well. My superclass automatically sets up the error method as a runmode (along with a few other standard runmodes that I use: login, logout, not_implemented, not_authorized, etc...)
It's so simple that I have to wonder whether it's even worth adding to CGI::App, even as a plug-in.
Simple for you since you have used it for a long time. Also simple for users once they see how easy this technique is. But not necesarily so simple to figure it out in the first place (at least not for everyone).
Although I agree that it might be difficult to write a generic plugin to handle this, since there are several different templating solutions that poeple use, and possibly other customizations as well.
Cheers,
Cees
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
