Created
March 30, 2010 22:05
-
-
Save perlDreamer/349650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm | |
index 0d54902..bbbe1d7 100644 | |
--- a/lib/WebGUI/SQL.pm | |
+++ b/lib/WebGUI/SQL.pm | |
@@ -429,9 +429,9 @@ sub connect { | |
my $params = shift; | |
my (undef, $driver) = DBI->parse_dsn($dsn); | |
- my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError => 0, AutoCommit => 1, | |
+ my $dbh = eval { DBI->connect($dsn,$user,$pass,{RaiseError => 0, AutoCommit => 1, | |
$driver eq 'mysql' ? (mysql_enable_utf8 => 1) : (), | |
- }); | |
+ }); }; | |
unless (defined $dbh) { | |
$session->errorHandler->error("Couldn't connect to database: $dsn : $DBI::errstr"); | |
diff --git a/lib/WebGUI/Session/ErrorHandler.pm b/lib/WebGUI/Session/ErrorHandler.pm | |
index 917fb6e..90a3546 100644 | |
--- a/lib/WebGUI/Session/ErrorHandler.pm | |
+++ b/lib/WebGUI/Session/ErrorHandler.pm | |
@@ -232,6 +232,7 @@ sub fatal { | |
if (! defined $self->session->db(1)) { | |
# We can't even _determine_ whether we can show the debug text. Punt. | |
$self->session->output->print("<h1>Fatal Internal Error</h1>"); | |
+ $self->session->output->print("<p>".$message."</p>"); | |
} | |
elsif ($self->canShowDebug()) { | |
$self->session->output->print("<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n",1); | |
diff --git a/lib/WebGUI/URL/Content.pm b/lib/WebGUI/URL/Content.pm | |
index 14a2d8f..f94dc12 100644 | |
--- a/lib/WebGUI/URL/Content.pm | |
+++ b/lib/WebGUI/URL/Content.pm | |
@@ -64,47 +64,50 @@ sub handler { | |
my ($request, $server, $config) = @_; | |
$request->push_handlers(PerlResponseHandler => sub { | |
my $session = $request->pnotes('wgSession'); | |
- unless (defined $session) { | |
- $session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server); | |
- } | |
- WEBGUI_FATAL: foreach my $handler (@{$config->get("contentHandlers")}) { | |
- my $output = eval { WebGUI::Pluggable::run($handler, "handler", [ $session ] )}; | |
- if ( my $e = WebGUI::Error->caught ) { | |
- $session->errorHandler->error($e->package.":".$e->line." - ".$e->error); | |
- $session->errorHandler->debug($e->package.":".$e->line." - ".$e->trace); | |
- } | |
- elsif ( $@ ) { | |
- $session->errorHandler->error( $@ ); | |
+ WEBGUI_FATAL: { | |
+ unless (defined $session) { | |
+ $session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server); | |
+ return Apache2::Const::OK if ! defined $session; | |
} | |
- else { | |
- if ($output eq "chunked") { | |
- if ($session->errorHandler->canShowDebug()) { | |
- $session->output->print($session->errorHandler->showDebug(),1); | |
- } | |
- last; | |
+ foreach my $handler (@{$config->get("contentHandlers")}) { | |
+ my $output = eval { WebGUI::Pluggable::run($handler, "handler", [ $session ] )}; | |
+ if ( my $e = WebGUI::Error->caught ) { | |
+ $session->errorHandler->error($e->package.":".$e->line." - ".$e->error); | |
+ $session->errorHandler->debug($e->package.":".$e->line." - ".$e->trace); | |
} | |
- if ($output eq "empty") { | |
- if ($session->errorHandler->canShowDebug()) { | |
- $session->output->print($session->errorHandler->showDebug(),1); | |
- } | |
- last; | |
+ elsif ( $@ ) { | |
+ $session->errorHandler->error( $@ ); | |
} | |
- elsif (defined $output && $output ne "") { | |
- $session->http->sendHeader; | |
- $session->output->print($output); | |
- if ($session->errorHandler->canShowDebug()) { | |
- $session->output->print($session->errorHandler->showDebug(),1); | |
+ else { | |
+ if ($output eq "chunked") { | |
+ if ($session->errorHandler->canShowDebug()) { | |
+ $session->output->print($session->errorHandler->showDebug(),1); | |
+ } | |
+ last; | |
+ } | |
+ if ($output eq "empty") { | |
+ if ($session->errorHandler->canShowDebug()) { | |
+ $session->output->print($session->errorHandler->showDebug(),1); | |
+ } | |
+ last; | |
+ } | |
+ elsif (defined $output && $output ne "") { | |
+ $session->http->sendHeader; | |
+ $session->output->print($output); | |
+ if ($session->errorHandler->canShowDebug()) { | |
+ $session->output->print($session->errorHandler->showDebug(),1); | |
+ } | |
+ last; | |
+ } | |
+ # Keep processing for success codes | |
+ elsif ($session->http->getStatus < 200 || $session->http->getStatus > 299) { | |
+ $session->http->sendHeader; | |
+ last; | |
} | |
- last; | |
- } | |
- # Keep processing for success codes | |
- elsif ($session->http->getStatus < 200 || $session->http->getStatus > 299) { | |
- $session->http->sendHeader; | |
- last; | |
} | |
} | |
} | |
- $session->close; | |
+ $session->close if defined $session; | |
return Apache2::Const::OK; | |
}); | |
$request->push_handlers(PerlMapToStorageHandler => sub { return Apache2::Const::OK }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment