Merge branch 'MDL-64961-master' of https://github.com/sammarshallou/moodle

This commit is contained in:
Andrew Nicols 2019-03-05 13:24:17 +08:00
commit 9aae08ac91

View File

@ -150,7 +150,9 @@ class webservice_rest_server extends webservice_base_server {
if ($this->restformat == 'json') {
$errorobject = new stdClass;
$errorobject->exception = get_class($ex);
$errorobject->errorcode = $ex->errorcode;
if (isset($ex->errorcode)) {
$errorobject->errorcode = $ex->errorcode;
}
$errorobject->message = $ex->getMessage();
if (debugging() and isset($ex->debuginfo)) {
$errorobject->debuginfo = $ex->debuginfo;
@ -159,8 +161,10 @@ class webservice_rest_server extends webservice_base_server {
} else {
$error = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$error .= '<EXCEPTION class="'.get_class($ex).'">'."\n";
$error .= '<ERRORCODE>' . htmlspecialchars($ex->errorcode, ENT_COMPAT, 'UTF-8')
. '</ERRORCODE>' . "\n";
if (isset($ex->errorcode)) {
$error .= '<ERRORCODE>' . htmlspecialchars($ex->errorcode, ENT_COMPAT, 'UTF-8')
. '</ERRORCODE>' . "\n";
}
$error .= '<MESSAGE>'.htmlspecialchars($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
if (debugging() and isset($ex->debuginfo)) {
$error .= '<DEBUGINFO>'.htmlspecialchars($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";