From 1e25da7eab1cc9ca572cfbab56b50e342558d631 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sat, 3 Apr 2010 03:36:11 +0000 Subject: #742246 by jbrown: Fixed Uncaught exceptions thrown in the exception handler prevent error reporting. --- includes/errors.inc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'includes/errors.inc') diff --git a/includes/errors.inc b/includes/errors.inc index 4ed7115e4..c82252cbc 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -87,7 +87,8 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c * * @param $exception * The exception object that was thrown. - * @return An error in the format expected by _drupal_log_error(). + * @return + * An error in the format expected by _drupal_log_error(). */ function _drupal_decode_exception($exception) { $message = $exception->getMessage(); @@ -125,6 +126,18 @@ function _drupal_decode_exception($exception) { ); } +/** + * Render an error message for an exception without any possibility of a further exception occuring. + * + * @param $exception + * The exception object that was thrown. + * @return + * An error message. + */ +function _drupal_render_exception_safe($exception) { + return strtr('%type: %message in %function (line %line of %file).', _drupal_decode_exception($exception)); +} + /** * Log a PHP error or exception, display an error page in fatal cases. * @@ -163,13 +176,7 @@ function _drupal_log_error($error, $fatal = FALSE) { $number++; } - try { - watchdog('php', '%type: %message in %function (line %line of %file).', $error, $error['severity_level']); - } - catch (Exception $e) { - // Ignore any additional watchdog exception, as that probably means - // that the database was not initialized correctly. - } + watchdog('php', '%type: %message in %function (line %line of %file).', $error, $error['severity_level']); if ($fatal) { drupal_add_http_header('Status', '500 Service unavailable (with message)'); -- cgit v1.2.3