mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Renaming error.php to error_handler.php to better match its class name.
This commit is contained in:
parent
756baeafdb
commit
88c66c057d
2 changed files with 20 additions and 35 deletions
|
@ -34,6 +34,6 @@ require LIBS . 'configure.php';
|
||||||
require LIBS . 'set.php';
|
require LIBS . 'set.php';
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
Configure::bootstrap();
|
Configure::bootstrap();
|
||||||
require LIBS . 'error.php';
|
require LIBS . 'error_handler.php';
|
||||||
set_exception_handler(array('ErrorHandler', 'handleException'));
|
set_exception_handler(array('ErrorHandler', 'handleException'));
|
||||||
require CAKE . 'dispatcher.php';
|
require CAKE . 'dispatcher.php';
|
||||||
|
|
|
@ -61,6 +61,7 @@ class ErrorHandler {
|
||||||
}
|
}
|
||||||
if ($method !== 'error') {
|
if ($method !== 'error') {
|
||||||
if (Configure::read('debug') == 0) {
|
if (Configure::read('debug') == 0) {
|
||||||
|
$code = $exception->getCode();
|
||||||
$parentClass = get_parent_class($this);
|
$parentClass = get_parent_class($this);
|
||||||
if ($parentClass != 'ErrorHandler') {
|
if ($parentClass != 'ErrorHandler') {
|
||||||
$method = 'error404';
|
$method = 'error404';
|
||||||
|
@ -69,7 +70,7 @@ class ErrorHandler {
|
||||||
if (in_array($method, $parentMethods)) {
|
if (in_array($method, $parentMethods)) {
|
||||||
$method = 'error404';
|
$method = 'error404';
|
||||||
}
|
}
|
||||||
if (isset($code) && $code == 500) {
|
if ($code == 500) {
|
||||||
$method = 'error500';
|
$method = 'error500';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,15 +192,12 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function missingAction($params) {
|
public function missingAction($error) {
|
||||||
extract($params, EXTR_OVERWRITE);
|
$message = $error->getMessage();
|
||||||
|
list($controllerName, $action) = explode('::', $message);
|
||||||
$controllerName = str_replace('Controller', '', $className);
|
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'controller' => $className,
|
'controller' => $controllerName,
|
||||||
'controllerName' => $controllerName,
|
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'title' => __('Missing Method in Controller')
|
|
||||||
));
|
));
|
||||||
$this->_outputMessage('missingAction');
|
$this->_outputMessage('missingAction');
|
||||||
}
|
}
|
||||||
|
@ -209,13 +207,12 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function privateAction($params) {
|
public function privateAction($error) {
|
||||||
extract($params, EXTR_OVERWRITE);
|
$message = $error->getMessage();
|
||||||
|
list($controllerName, $action) = explode('::', $message);
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'controller' => $className,
|
'controller' => $controllerName,
|
||||||
'action' => $action,
|
'action' => $action
|
||||||
'title' => __('Trying to access private method in class')
|
|
||||||
));
|
));
|
||||||
$this->_outputMessage('privateAction');
|
$this->_outputMessage('privateAction');
|
||||||
}
|
}
|
||||||
|
@ -225,15 +222,11 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function missingTable($params) {
|
public function missingTable($error) {
|
||||||
extract($params, EXTR_OVERWRITE);
|
|
||||||
|
|
||||||
$this->controller->header("HTTP/1.0 500 Internal Server Error");
|
$this->controller->header("HTTP/1.0 500 Internal Server Error");
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'code' => '500',
|
'model' => $error->getModel(),
|
||||||
'model' => $className,
|
'table' => $error->getTable(),
|
||||||
'table' => $table,
|
|
||||||
'title' => __('Missing Database Table')
|
|
||||||
));
|
));
|
||||||
$this->_outputMessage('missingTable');
|
$this->_outputMessage('missingTable');
|
||||||
}
|
}
|
||||||
|
@ -243,7 +236,7 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function missingDatabase($params = array()) {
|
public function missingDatabase($exception) {
|
||||||
$this->controller->header("HTTP/1.0 500 Internal Server Error");
|
$this->controller->header("HTTP/1.0 500 Internal Server Error");
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'code' => '500',
|
'code' => '500',
|
||||||
|
@ -257,14 +250,9 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function missingView($params) {
|
public function missingView($error) {
|
||||||
extract($params, EXTR_OVERWRITE);
|
|
||||||
|
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'controller' => $className,
|
'file' => $error->getMessage(),
|
||||||
'action' => $action,
|
|
||||||
'file' => $file,
|
|
||||||
'title' => __('Missing View')
|
|
||||||
));
|
));
|
||||||
$this->_outputMessage('missingView');
|
$this->_outputMessage('missingView');
|
||||||
}
|
}
|
||||||
|
@ -274,13 +262,10 @@ class ErrorHandler {
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param array $params Parameters for controller
|
||||||
*/
|
*/
|
||||||
public function missingLayout($params) {
|
public function missingLayout($error) {
|
||||||
extract($params, EXTR_OVERWRITE);
|
|
||||||
|
|
||||||
$this->controller->layout = 'default';
|
$this->controller->layout = 'default';
|
||||||
$this->controller->set(array(
|
$this->controller->set(array(
|
||||||
'file' => $file,
|
'file' => $error->getMessage(),
|
||||||
'title' => __('Missing Layout')
|
|
||||||
));
|
));
|
||||||
$this->_outputMessage('missingLayout');
|
$this->_outputMessage('missingLayout');
|
||||||
}
|
}
|
Loading…
Reference in a new issue