Skip to content

Commit

Permalink
Fixing ExceptionRenderer so it can render exceptions that are subclasses
Browse files Browse the repository at this point in the history
of CakeException that do not have custom templates, like ConfigureException.
Removing $lastError as it doesn't work.
Added tests.
  • Loading branch information
markstory committed Apr 16, 2011
1 parent c1a8dbb commit a7a076d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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');
}
}

/**
Expand Down Expand Up @@ -234,4 +235,4 @@ protected function _outputMessage($template) {
$this->controller->afterFilter();
$this->controller->response->send();
}
}
}
10 changes: 10 additions & 0 deletions lib/Cake/tests/Case/Error/ExceptionRendererTest.php
Expand Up @@ -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
)
);
}
Expand Down

0 comments on commit a7a076d

Please sign in to comment.