From fb71453ddca4ddd73dfcce8033d57cb1a3a5e139 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Tue, 6 Mar 2012 12:46:23 +0700 Subject: [PATCH] MDL-30434 core: modified get_exception_info() to provide more debug information --- lib/setuplib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/setuplib.php b/lib/setuplib.php index 1c0f5f642de..7df31332f54 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -489,6 +489,9 @@ function get_exception_info($ex) { $debuginfo = null; } + // Append the error code to the debug info to make grepping and googling easier + $debuginfo .= PHP_EOL."Error code: $errorcode"; + $backtrace = $ex->getTrace(); $place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex)); array_unshift($backtrace, $place); @@ -497,6 +500,8 @@ function get_exception_info($ex) { if (empty($module) || $module == 'moodle' || $module == 'core') { $module = 'error'; } + // Search for the $errorcode's associated string + // If not found, append the contents of $a to $debuginfo so helpful information isn't lost if (function_exists('get_string_manager')) { if (get_string_manager()->string_exists($errorcode, $module)) { $message = get_string($errorcode, $module, $a); @@ -505,9 +510,11 @@ function get_exception_info($ex) { $message = get_string($errorcode, 'moodle', $a); } else { $message = $module . '/' . $errorcode; + $debuginfo .= PHP_EOL.'$a contents: '.print_r($a, true); } } else { $message = $module . '/' . $errorcode; + $debuginfo .= PHP_EOL.'$a contents: '.print_r($a, true); } // Be careful, no guarantee weblib.php is loaded.