webservice MDL-25444 indicate which field are unexpected in case of web service error

This commit is contained in:
jerome mouneyrac 2010-11-30 01:55:17 +00:00
parent a7a1dbd632
commit ceb1bad4ad
2 changed files with 7 additions and 2 deletions

View File

@ -85,7 +85,7 @@ $string['erroronlyarray'] = 'Only arrays accepted.';
$string['erroroptionalparamarray'] = 'The web service description parameter named \'{$a}\' is an single or multiple structure. It can not be set as VALUE_OPTIONAL. Check web service description.';
$string['errorresponsemissingkey'] = 'Error in response - Missing following required key in a single structure: {$a}';
$string['errorscalartype'] = 'Scalar type expected, array or object received.';
$string['errorunexpectedkey'] = 'Unexpected keys detected in parameter array.';
$string['errorunexpectedkey'] = 'Unexpected keys ({$a}) detected in parameter array.';
$string['execute'] = 'Execute';
$string['executewarnign'] = 'WARNING: If you press execute your database will be modified and changes can not be reverted automatically!';
$string['externalservice'] = 'External service';

View File

@ -185,7 +185,12 @@ class external_api {
unset($params[$key]);
}
if (!empty($params)) {
throw new invalid_parameter_exception(get_string('errorunexpectedkey', 'webservice'));
//list all unexpected keys
$keys = '';
foreach($params as $key => $value) {
$keys .= $key . ',';
}
throw new invalid_parameter_exception(get_string('errorunexpectedkey', 'webservice', $keys));
}
return $result;