diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index e971b38c1..cf2409ddc 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -107,31 +107,32 @@ class ErrorHandler { * @see http://php.net/manual/en/function.set-exception-handler.php */ public static function handleException(Exception $exception) { + $config = Configure::read('Exception'); + if (!empty($config['log'])) { + $message = sprintf("[%s] %s\n%s", + get_class($exception), + $exception->getMessage(), + $exception->getTraceAsString() + ); + CakeLog::write(LOG_ERR, $message); + } + $renderer = $config['renderer']; + if ($renderer !== 'ExceptionRenderer') { + list($plugin, $renderer) = pluginSplit($renderer, true); + App::uses($renderer, $plugin . 'Error'); + } try { - $config = Configure::read('Exception'); - if (!empty($config['log'])) { - $message = sprintf("[%s] %s\n%s", - get_class($exception), - $exception->getMessage(), - $exception->getTraceAsString() - ); - CakeLog::write(LOG_ERR, $message); - } - $renderer = $config['renderer']; - if ($renderer !== 'ExceptionRenderer') { - list($plugin, $renderer) = pluginSplit($renderer, true); - App::uses($renderer, $plugin . 'Error'); - } $error = new $renderer($exception); $error->render(); } catch (Exception $e) { - $message = $e->getMessage()."\nCall Stack:\n".$e->getTraceAsString(); - ErrorHandler::handleError( - E_ERROR, - $message, - $e->getFile(), - $e->getLine() + set_error_handler(Configure::read('Error.handler')); // Should be using configured ErrorHandler + Configure::write('Error.trace', false); // trace is useless here since it's internal + $message = sprintf("[%s] %s\n%s", // Keeping same message format + get_class($e), + $e->getMessage(), + $e->getTraceAsString() ); + trigger_error($message, E_USER_ERROR); } }