mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing ExceptionRenderer so it can render exceptions that are subclasses
of CakeException that do not have custom templates, like ConfigureException. Removing $lastError as it doesn't work. Added tests.
This commit is contained in:
parent
c1a8dbbce7
commit
a7a076dbee
2 changed files with 19 additions and 8 deletions
|
@ -143,13 +143,10 @@ class ExceptionRenderer {
|
||||||
* @return Controller
|
* @return Controller
|
||||||
*/
|
*/
|
||||||
protected function _getController($exception) {
|
protected function _getController($exception) {
|
||||||
static $__previousError = null;
|
|
||||||
App::uses('CakeErrorController', 'Controller');
|
App::uses('CakeErrorController', 'Controller');
|
||||||
|
try {
|
||||||
if ($__previousError != $exception) {
|
|
||||||
$__previousError = $exception;
|
|
||||||
$controller = new CakeErrorController(Router::getRequest(false));
|
$controller = new CakeErrorController(Router::getRequest(false));
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
$controller = new Controller(Router::getRequest(false));
|
$controller = new Controller(Router::getRequest(false));
|
||||||
$controller->viewPath = 'errors';
|
$controller->viewPath = 'errors';
|
||||||
}
|
}
|
||||||
|
@ -183,8 +180,12 @@ class ExceptionRenderer {
|
||||||
'name' => $error->getMessage(),
|
'name' => $error->getMessage(),
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
));
|
));
|
||||||
|
try {
|
||||||
$this->controller->set($error->getAttributes());
|
$this->controller->set($error->getAttributes());
|
||||||
$this->_outputMessage($this->template);
|
$this->_outputMessage($this->template);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->_outputMessage('error500');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -574,6 +574,16 @@ class ExceptionRendererTest extends CakeTestCase {
|
||||||
'/Internal Error/'
|
'/Internal Error/'
|
||||||
),
|
),
|
||||||
500
|
500
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
new CakeException('base class'),
|
||||||
|
array('/Internal Error/'),
|
||||||
|
500
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
new ConfigureException('No file'),
|
||||||
|
array('/Internal Error/'),
|
||||||
|
500
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue