return TALER_EC_INVALID instead of TALER_EC_NONE when error JSON doesn't contain code

This commit is contained in:
Florian Dold 2020-01-23 15:44:33 +01:00
parent 0fe82acc1b
commit 26c9563ef0
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -77,8 +77,13 @@ TALER_JSON_get_error_code (const json_t *json)
return TALER_EC_INVALID_RESPONSE; return TALER_EC_INVALID_RESPONSE;
} }
jc = json_object_get (json, "code"); jc = json_object_get (json, "code");
/* The caller already knows that the JSON represents an error,
so we are dealing with a missing error code here. */
if (NULL == jc) if (NULL == jc)
return TALER_EC_NONE; {
GNUNET_break_op (0);
return TALER_EC_INVALID;
}
if (json_is_integer (jc)) if (json_is_integer (jc))
return (enum TALER_ErrorCode) json_integer_value (jc); return (enum TALER_ErrorCode) json_integer_value (jc);
GNUNET_break_op (0); GNUNET_break_op (0);