From 8c428ff8a89a33c4165026cd58e38b7e8b537c39 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 3 Sep 2010 15:03:33 -0400 Subject: [PATCH] Moving where AppError is used, as infinite recursion is no fun. --- cake/libs/error_handler.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cake/libs/error_handler.php b/cake/libs/error_handler.php index 5d147f476..3b59f55da 100644 --- a/cake/libs/error_handler.php +++ b/cake/libs/error_handler.php @@ -99,10 +99,6 @@ class ErrorHandler { if (method_exists($this->controller, 'apperror')) { return $this->controller->appError($exception); } - if (file_exists(APP . 'app_error.php') && class_exists('AppError')) { - $AppError = new AppError($exception); - return $AppError->render(); - } $method = $template = Inflector::variable(str_replace('Exception', '', get_class($exception))); if ($exception instanceof CakeException && !in_array($method, get_class_methods($this))) { @@ -155,13 +151,21 @@ class ErrorHandler { /** * Set as the default exception handler by the CakePHP bootstrap process. - * If you wish you use a custom default exception handler use set_exception_handler() - * in your app/config/bootstrap.php. + * + * This will either use an AppError class if your application has one, + * or use the default ErrorHandler. * * @return void * @see http://php.net/manual/en/function.set-exception-handler.php */ public static function handleException(Exception $exception) { + if (file_exists(APP . 'app_error.php') || class_exists('AppError')) { + if (!class_exists('AppError')) { + require(APP . 'app_error.php'); + } + $AppError = new AppError($exception); + return $AppError->render(); + } $error = new ErrorHandler($exception); $error->render(); }