added a not found handler, and better debug handling

This commit is contained in:
JT Smith 2007-12-14 22:43:08 +00:00
parent 1fc11fbda8
commit 09ac71093b
3 changed files with 68 additions and 14 deletions

View file

@ -135,9 +135,6 @@ sub handler {
$http->sendHeader(); #http object will only send the header once per request, so if the above sent a header as part of it's operation, this will do nothing.
unless ($http->isRedirect()) {
$session->output->print($output);
if ($errorHandler->canShowDebug()) {
$session->output->print($errorHandler->showDebug(),1);
}
}
# ...
return $output;
@ -180,16 +177,6 @@ sub page {
if ($session->var->isAdminOn) { # they're expecting it to be there, so let's help them add it
my $asset = WebGUI::Asset->newByUrl($session, $session->url->getRefererUrl) || WebGUI::Asset->getDefault($session);
$output = $asset->addMissing($assetUrl);
} else { # not in admin mode, so can't create it, so display not found
$session->http->setStatus("404","Page Not Found");
my $notFound = WebGUI::Asset->getNotFound($session);
if (defined $notFound) {
$output = tryAssetMethod($session,$notFound,'view');
} else {
$session->errorHandler->error("The notFound page could not be instanciated!");
$output = "An error was encountered while processing your request.";
}
$output = "An error was encountered while processing your request." if $output eq '';
}
}
if ($output eq "chunked") {

View file

@ -0,0 +1,64 @@
package WebGUI::Content::NotFound;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2007 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use WebGUI::Asset;
=head1 NAME
Package WebGUI::Content::NotFound
=head1 DESCRIPTION
A content handler that displays a default page when no other content is produced.
=head1 SYNOPSIS
use WebGUI::Content::NotFound;
my $output = WebGUI::Content::NotFound::handler($session);
=head1 SUBROUTINES
These subroutines are available from this package:
=cut
#-------------------------------------------------------------------
=head2 handler ( session )
The content handler for this package.
=cut
sub handler {
my ($session) = @_;
$session->http->setStatus("404","Page Not Found");
my $output = "";
my $notFound = WebGUI::Asset->getNotFound($session);
if (defined $notFound) {
$output = eval { $notFound->www_view };
}
else {
$session->errorHandler->error("The notFound page could not be instanciated!");
$output = "An error was encountered while processing your request.";
}
$output = "An error was encountered while processing your request." if $output eq '';
return $output;
}
1;

View file

@ -64,7 +64,10 @@ sub handler {
use strict;
if ($output) {
unless ($output eq "none" || $output eq "redirect") {
$session->output->print($output);
$session->output->print($output) unless ($output eq "chunked");
if ($session->errorHandler->canShowDebug()) {
$session->output->print($session->errorHandler->showDebug(),1);
}
}
last;
}