webservice MDL-23440 more explicit error message when validation context fail in some external functions.

This commit is contained in:
jerome mouneyrac 2010-07-30 06:00:32 +00:00
parent 451f1e3844
commit 41e962ffb0
2 changed files with 72 additions and 8 deletions

View file

@ -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);