diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index b33d2e458..a78f43b60 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -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") { diff --git a/lib/WebGUI/Content/NotFound.pm b/lib/WebGUI/Content/NotFound.pm new file mode 100644 index 000000000..b759832cf --- /dev/null +++ b/lib/WebGUI/Content/NotFound.pm @@ -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; + diff --git a/lib/WebGUI/URL/Content.pm b/lib/WebGUI/URL/Content.pm index 032a0ce83..6035b9e63 100644 --- a/lib/WebGUI/URL/Content.pm +++ b/lib/WebGUI/URL/Content.pm @@ -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; }