Skip to content

Commit

Permalink
webservice MDL-25444 indicate which field are unexpected in case of w…
Browse files Browse the repository at this point in the history
…eb service error
  • Loading branch information
mouneyrac committed Nov 30, 2010
1 parent a7a1dbd commit ceb1bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lang/en/webservice.php
Expand Up @@ -85,7 +85,7 @@
$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';
Expand Down
7 changes: 6 additions & 1 deletion lib/externallib.php
Expand Up @@ -185,7 +185,12 @@ public static function validate_parameters(external_description $description, $p
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;

Expand Down

0 comments on commit ceb1bad

Please sign in to comment.