/** * handleException * * @param Exception $exception */ public static function handleException(Exception $exception) { /** * @see ErrorHandler::handleException */ $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'); } $force = Configure::read('ExceptionNotifier.force'); $debug = Configure::read('debug'); if (($force || $debug == 0) && self::_checkAllowed($exception)) { $prefix = Configure::read('ExceptionNotifier.prefix'); $subject = $prefix . '[' . date('Ymd H:i:s') . '][Exception][' . ExceptionText::getUrl() . '] ' . $exception->getMessage(); $body = ExceptionText::getBody($exception->getMessage(), $exception->getFile(), $exception->getLine()); ExceptionMail::send($subject, $body); } /** * @see ErrorHandler::handleException */ try { $error = new $renderer($exception); $error->render(); } catch (Exception $e) { 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", get_class($e), $e->getMessage(), $e->getTraceAsString()); trigger_error($message, E_USER_ERROR); } }