From: Eloy Lafuente (stronk7) Date: Tue, 12 Feb 2013 00:07:43 +0000 (+0100) Subject: Merge branch 'MDL-37919-phpunit-exception' of git://github.com/mudrd8mz/moodle X-Git-Tag: v2.5.0-beta~555 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=ef1a4d20d4ff6b7ac175a19b86c4db52a89943d0;hp=9a061c328596946783ae92b1b2ea95e1f05df9b0 Merge branch 'MDL-37919-phpunit-exception' of git://github.com/mudrd8mz/moodle --- diff --git a/lib/setuplib.php b/lib/setuplib.php index 8063d0b907a..34ead8c9156 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -137,14 +137,23 @@ class moodle_exception extends Exception { if (get_string_manager()->string_exists($errorcode, $module)) { $message = get_string($errorcode, $module, $a); + $haserrorstring = true; } else { $message = $module . '/' . $errorcode; + $haserrorstring = false; } if (defined('PHPUNIT_TEST') and PHPUNIT_TEST and $debuginfo) { $message = "$message ($debuginfo)"; } + if (!$haserrorstring and defined('PHPUNIT_TEST') and PHPUNIT_TEST) { + // Append the contents of $a to $debuginfo so helpful information isn't lost. + // This emulates what {@link get_exception_info()} does. Unfortunately that + // function is not used by phpunit. + $message .= PHP_EOL.'$a contents: '.print_r($a, true); + } + parent::__construct($message, 0); } }