Egg::Plugin::ErrorDocument - Plugin to display original error screen for Egg.
package MYPROJECT; use strict; sue Egg qw{ ErrorDocument };
Configuration.
plugin_error_document=> { view_name => 'Mason', template_name => '/error/document.tt', default_status => 404, ignore_status => 200, no_cache => 1, },
Template : /MYPROJECT_ROOT/comp/error/document.tt
<%init> my $code= $e->stash->{response_code}; </%init> % <html> <head> <title><% $e->page_title %></title> </head> <body> <h1><% $e->page_title %></h1> <hr> <p> % if ($code == 401) { Un authorized. ..... ... .. % } elsif ($code == 403) { Forbidden. ..... ... .. % } elsif ($code == 404) { Object Not Found. ..... ... .. % } elsif ($code == 500) { Internal Server Error. ..... ... .. % } else { Internal Error. ..... ... .. % } </p> </body> </html>
This plugin displays the original error page.
It doesn't live well in usual CGI and FastCGI though it only has to leave 'mod_perl' to the server now if an appropriate result code is returned when processing is ended. Then, this plug-in helps to make and to output the error page matched to the response code.
Because it relies on a prescribed template, the place of VIEW and the template for the template will be set to the configuration in making the error page.
The name of View to handle the template is set.
As for default, the one whose priority level is the highest in the setting of VIEW is used.
The template to generate the error page is set.
It should be a form that can be treated with View specified with view_name though is not to saying.
There is no default. It makes an error of the unspecification.
The code that wants to do to the default when it is called like the response status undefinition is set.
Default is '404'.
The response code in which nothing is done is specified.
Default is '200'.
The data to obtain the character corresponding to the status code is set by the HASH reference.
Default is { 401 => 'AUTH_REQUIRED', 403 => 'FORBIDDEN', 404 => 'NOT_FOUND', 500 => 'SERVER_ERROR', }
When the error page is output, the no_cache header is included.
* I think the no_cache header also for the thing erased by the proxy etc. to exist. When the following sources are included in the template, it is more certain.
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"> <meta http-equiv="expires" content="0">
It is called at the end of processing if it is assumed $e->finished(404) usually.
The error page is output to the making client.
The character corresponding to the status code is returned.
'INTERNAL_ERROR' returns when the corresponding one is not found.
The data set with status_codeset is used.
Egg::Engine, Egg::Release,
Masatoshi Mizuno, <lushe@cpan.org>
Copyright (C) 2007 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Egg::Release, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release
CPAN shell
perl -MCPAN -e shell install Egg::Release
For more information on module installation, please visit the detailed CPAN module installation guide.