mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-63303 core: add debug info to exceptions
This commit is contained in:
parent
9d199fd2e7
commit
c912cd7324
@ -98,6 +98,8 @@ class moodle_exception extends Exception {
|
||||
* @param string $debuginfo optional debugging information
|
||||
*/
|
||||
function __construct($errorcode, $module='', $link='', $a=NULL, $debuginfo=null) {
|
||||
global $CFG;
|
||||
|
||||
if (empty($module) || $module == 'moodle' || $module == 'core') {
|
||||
$module = 'error';
|
||||
}
|
||||
@ -116,11 +118,21 @@ class moodle_exception extends Exception {
|
||||
$haserrorstring = false;
|
||||
}
|
||||
|
||||
if (defined('PHPUNIT_TEST') and PHPUNIT_TEST and $debuginfo) {
|
||||
$message = "$message ($debuginfo)";
|
||||
$isinphpunittest = (defined('PHPUNIT_TEST') && PHPUNIT_TEST);
|
||||
$hasdebugdeveloper = (
|
||||
isset($CFG->debugdisplay) &&
|
||||
isset($CFG->debug) &&
|
||||
$CFG->debugdisplay &&
|
||||
$CFG->debug === DEBUG_DEVELOPER
|
||||
);
|
||||
|
||||
if ($debuginfo) {
|
||||
if ($isinphpunittest || $hasdebugdeveloper) {
|
||||
$message = "$message ($debuginfo)";
|
||||
}
|
||||
}
|
||||
|
||||
if (!$haserrorstring and defined('PHPUNIT_TEST') and PHPUNIT_TEST) {
|
||||
if (!$haserrorstring and $isinphpunittest) {
|
||||
// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user