Skip to content

Commit

Permalink
Renaming error.php to error_handler.php to better match its class name.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 29, 2010
1 parent 756baea commit 88c66c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cake/bootstrap.php
Expand Up @@ -34,6 +34,6 @@
require LIBS . 'set.php';
require LIBS . 'cache.php';
Configure::bootstrap();
require LIBS . 'error.php';
require LIBS . 'error_handler.php';
set_exception_handler(array('ErrorHandler', 'handleException'));
require CAKE . 'dispatcher.php';
53 changes: 19 additions & 34 deletions cake/libs/error.php → cake/libs/error_handler.php
Expand Up @@ -61,6 +61,7 @@ function __construct(Exception $exception) {
}
if ($method !== 'error') {
if (Configure::read('debug') == 0) {
$code = $exception->getCode();
$parentClass = get_parent_class($this);
if ($parentClass != 'ErrorHandler') {
$method = 'error404';
Expand All @@ -69,7 +70,7 @@ function __construct(Exception $exception) {
if (in_array($method, $parentMethods)) {
$method = 'error404';
}
if (isset($code) && $code == 500) {
if ($code == 500) {
$method = 'error500';
}
}
Expand Down Expand Up @@ -191,15 +192,12 @@ public function missingController($params) {
*
* @param array $params Parameters for controller
*/
public function missingAction($params) {
extract($params, EXTR_OVERWRITE);

$controllerName = str_replace('Controller', '', $className);
public function missingAction($error) {
$message = $error->getMessage();
list($controllerName, $action) = explode('::', $message);
$this->controller->set(array(
'controller' => $className,
'controllerName' => $controllerName,
'controller' => $controllerName,
'action' => $action,
'title' => __('Missing Method in Controller')
));
$this->_outputMessage('missingAction');
}
Expand All @@ -209,13 +207,12 @@ public function missingAction($params) {
*
* @param array $params Parameters for controller
*/
public function privateAction($params) {
extract($params, EXTR_OVERWRITE);

public function privateAction($error) {
$message = $error->getMessage();
list($controllerName, $action) = explode('::', $message);
$this->controller->set(array(
'controller' => $className,
'action' => $action,
'title' => __('Trying to access private method in class')
'controller' => $controllerName,
'action' => $action
));
$this->_outputMessage('privateAction');
}
Expand All @@ -225,15 +222,11 @@ public function privateAction($params) {
*
* @param array $params Parameters for controller
*/
public function missingTable($params) {
extract($params, EXTR_OVERWRITE);

public function missingTable($error) {
$this->controller->header("HTTP/1.0 500 Internal Server Error");
$this->controller->set(array(
'code' => '500',
'model' => $className,
'table' => $table,
'title' => __('Missing Database Table')
'model' => $error->getModel(),
'table' => $error->getTable(),
));
$this->_outputMessage('missingTable');
}
Expand All @@ -243,7 +236,7 @@ public function missingTable($params) {
*
* @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->set(array(
'code' => '500',
Expand All @@ -257,14 +250,9 @@ public function missingDatabase($params = array()) {
*
* @param array $params Parameters for controller
*/
public function missingView($params) {
extract($params, EXTR_OVERWRITE);

public function missingView($error) {
$this->controller->set(array(
'controller' => $className,
'action' => $action,
'file' => $file,
'title' => __('Missing View')
'file' => $error->getMessage(),
));
$this->_outputMessage('missingView');
}
Expand All @@ -274,13 +262,10 @@ public function missingView($params) {
*
* @param array $params Parameters for controller
*/
public function missingLayout($params) {
extract($params, EXTR_OVERWRITE);

public function missingLayout($error) {
$this->controller->layout = 'default';
$this->controller->set(array(
'file' => $file,
'title' => __('Missing Layout')
'file' => $error->getMessage(),
));
$this->_outputMessage('missingLayout');
}
Expand Down

0 comments on commit 88c66c0

Please sign in to comment.