mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
webservice MDL-23440 more explicit error message when validation context fail in some external functions.
This commit is contained in:
parent
451f1e3844
commit
41e962ffb0
2 changed files with 72 additions and 8 deletions
|
@ -72,7 +72,15 @@ class moodle_enrol_external extends external_api {
|
|||
$context = $coursecontext;
|
||||
}
|
||||
|
||||
self::validate_context($context);
|
||||
try {
|
||||
self::validate_context($context);
|
||||
} catch (Exception $e) {
|
||||
$exceptionparam = new stdClass();
|
||||
$exceptionparam->message = $e->getMessage();
|
||||
$exceptionparam->courseid = $params['courseid'];
|
||||
throw new moodle_exception(
|
||||
get_string('errorcoursecontextnotvalid' , 'webservice', $exceptionparam));
|
||||
}
|
||||
|
||||
if ($courseid == SITEID) {
|
||||
require_capability('moodle/site:viewparticipants', $context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue