webservice MDL-12886 exception more explicit when clean response value fail

This commit is contained in:
jerome mouneyrac 2010-07-14 07:33:26 +00:00
parent fde884c342
commit 476c0e82d3
2 changed files with 2 additions and 1 deletions

View File

@ -76,6 +76,7 @@ $string['errormissingkey'] = 'Missing required key in single structure: {$a}';
$string['errornotemptydefaultparamarray'] = 'The web service description parameter named \'{$a}\' is an single or multiple structure. The default can only be empty array. Check web service description.';
$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['execute'] = 'Execute';

View File

@ -235,7 +235,7 @@ class external_api {
foreach ($description->keys as $key=>$subdesc) {
if (!array_key_exists($key, $response)) {
if ($subdesc->required == VALUE_REQUIRED) {
throw new invalid_response_exception(get_string('errormissingkey', 'webservice', $key));
throw new webservice_parameter_exception('errorresponsemissingkey', $key);
}
if ($subdesc instanceof external_value) {
if ($subdesc->required == VALUE_DEFAULT) {