Skip to content

Commit

Permalink
Item13897: Don't use die when $app or $app->engine failed to initiali…
Browse files Browse the repository at this point in the history
…ze and a fatal exception is raised.
  • Loading branch information
vrurg committed Oct 24, 2016
1 parent cddb9d7 commit 06c6883
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions core/lib/Foswiki/App.pm
Expand Up @@ -471,11 +471,11 @@ sub run {

my $errStr = Foswiki::Exception::errorStr($e);

$errStr = '<pre>' . Foswiki::entityEncode($errStr) . '</pre>';

# Low-level report of errors to user.
if ( defined $app && $app->has_engine ) {

$errStr = '<pre>' . Foswiki::entityEncode($errStr) . '</pre>';

# Send error output to user using the initialized engine.
$rc = $app->engine->finalizeReturn(
[
Expand All @@ -490,7 +490,17 @@ sub run {
}
else {
# Propagade the error using the most primitive way.
die $errStr;
my $errBody = join( '',
'<html>', '<head>', '</head>', '<body>',
$errStr, '</body>', '</html>', );
$rc = [
500,
[
'Content-Type' => 'text/html; charset=utf-8',
'Content-Length' => length($errStr),
],
[$errBody],
];
}
};
return $rc;
Expand Down

0 comments on commit 06c6883

Please sign in to comment.