diff --git a/lib/externallib.php b/lib/externallib.php index 002a99d2dee..50cd9da668d 100644 --- a/lib/externallib.php +++ b/lib/externallib.php @@ -84,11 +84,12 @@ class external_api { $function->classpath = $CFG->dirroot.'/'.$function->classpath; } if (!file_exists($function->classpath)) { - throw new coding_exception('Cannot find file with external function implementation'); + throw new coding_exception('Cannot find file ' . $function->classpath . + ' with external function implementation'); } require_once($function->classpath); if (!class_exists($function->classname)) { - throw new coding_exception('Cannot find external class'); + throw new coding_exception('Cannot find external class ' . $function->classname); } } @@ -99,13 +100,16 @@ class external_api { // Make sure the implementaion class is ok. if (!method_exists($function->classname, $function->methodname)) { - throw new coding_exception('Missing implementation method of '.$function->classname.'::'.$function->methodname); + throw new coding_exception('Missing implementation method ' . + $function->classname . '::' . $function->methodname); } if (!method_exists($function->classname, $function->parameters_method)) { - throw new coding_exception('Missing parameters description'); + throw new coding_exception('Missing parameters description method ' . + $function->classname . '::' . $function->parameters_method); } if (!method_exists($function->classname, $function->returns_method)) { - throw new coding_exception('Missing returned values description'); + throw new coding_exception('Missing returned values description method ' . + $function->classname . '::' . $function->returns_method); } if (method_exists($function->classname, $function->deprecated_method)) { if (call_user_func(array($function->classname, $function->deprecated_method)) === true) { @@ -117,14 +121,16 @@ class external_api { // Fetch the parameters description. $function->parameters_desc = call_user_func(array($function->classname, $function->parameters_method)); if (!($function->parameters_desc instanceof external_function_parameters)) { - throw new coding_exception('Invalid parameters description'); + throw new coding_exception($function->classname . '::' . $function->parameters_method . + ' did not return a valid external_function_parameters object.'); } // Fetch the return values description. $function->returns_desc = call_user_func(array($function->classname, $function->returns_method)); // Null means void result or result is ignored. if (!is_null($function->returns_desc) and !($function->returns_desc instanceof external_description)) { - throw new coding_exception('Invalid return description'); + throw new coding_exception($function->classname . '::' . $function->returns_method . + ' did not return a valid external_description object'); } // Now get the function description.