diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 761aae0c451..eb3fbfe954e 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -143,13 +143,10 @@ function __construct(Exception $exception) { * @return Controller */ protected function _getController($exception) { - static $__previousError = null; App::uses('CakeErrorController', 'Controller'); - - if ($__previousError != $exception) { - $__previousError = $exception; + try { $controller = new CakeErrorController(Router::getRequest(false)); - } else { + } catch (Exception $e) { $controller = new Controller(Router::getRequest(false)); $controller->viewPath = 'errors'; } @@ -183,8 +180,12 @@ protected function _cakeError(CakeException $error) { 'name' => $error->getMessage(), 'error' => $error, )); - $this->controller->set($error->getAttributes()); - $this->_outputMessage($this->template); + try { + $this->controller->set($error->getAttributes()); + $this->_outputMessage($this->template); + } catch (Exception $e) { + $this->_outputMessage('error500'); + } } /** @@ -234,4 +235,4 @@ protected function _outputMessage($template) { $this->controller->afterFilter(); $this->controller->response->send(); } -} \ No newline at end of file +} diff --git a/lib/Cake/tests/Case/Error/ExceptionRendererTest.php b/lib/Cake/tests/Case/Error/ExceptionRendererTest.php index 950caba7856..3017f125be0 100644 --- a/lib/Cake/tests/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/tests/Case/Error/ExceptionRendererTest.php @@ -574,6 +574,16 @@ public static function testProvider() { '/Internal Error/' ), 500 + ), + array( + new CakeException('base class'), + array('/Internal Error/'), + 500 + ), + array( + new ConfigureException('No file'), + array('/Internal Error/'), + 500 ) ); }