From ee7369ed0edac325f6727b92295e72162f4f3760 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sun, 22 Mar 2015 15:26:47 -0400 Subject: [PATCH] Clean up the internals of JErrorPage to improve testability --- libraries/cms/error/page.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libraries/cms/error/page.php b/libraries/cms/error/page.php index 4f1488786b4a2..5f46a07b7d7d8 100644 --- a/libraries/cms/error/page.php +++ b/libraries/cms/error/page.php @@ -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(); @@ -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) { @@ -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()); } } }