Skip to content

Commit

Permalink
Clean up the internals of JErrorPage to improve testability
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Mar 22, 2015
1 parent 8f2e282 commit ee7369e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions libraries/cms/error/page.php
Expand Up @@ -35,11 +35,9 @@ public static function render(Exception $error)
if (!$document)
{
// We're probably in an CLI environment
exit($error->getMessage());
jexit($error->getMessage());
}

$config = JFactory::getConfig();

// Get the current template from the application
$template = $app->getTemplate();

Expand All @@ -52,26 +50,28 @@ public static function render(Exception $error)
}

$document->setTitle(JText::_('Error') . ': ' . $error->getCode());

$data = $document->render(
false,
array('template' => $template,
'directory' => JPATH_THEMES,
'debug' => $config->get('debug'))
array(
'template' => $template,
'directory' => JPATH_THEMES,
'debug' => JDEBUG
)
);

// Failsafe to get the error displayed.
// Do not allow cache
$app->allowCache(false);

// If nothing was rendered, just use the message from the Exception
if (empty($data))
{
exit($error->getMessage());
$data = $error->getMessage();
}
else
{
// Do not allow cache
$app->allowCache(false);

$app->setBody($data);
echo $app->toString();
}
$app->setBody($data);

echo $app->toString();
}
catch (Exception $e)
{
Expand All @@ -81,7 +81,7 @@ public static function render(Exception $error)
header('HTTP/1.1 500 Internal Server Error');
}

exit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage());
jexit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage());
}
}
}

0 comments on commit ee7369e

Please sign in to comment.