add another helper
This commit is contained in:
parent
b7a5af7fd4
commit
70a210ac4d
@ -126,6 +126,19 @@ enum TALER_ErrorCode
|
|||||||
TALER_JSON_get_error_code (const json_t *json);
|
TALER_JSON_get_error_code (const json_t *json);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the Taler error code from the given @a data object, which is expected to be in JSON.
|
||||||
|
* Note that #TALER_EC_INVALID is returned if no "code" is present or if @a data is not in JSON.
|
||||||
|
*
|
||||||
|
* @param data response to extract the error code from
|
||||||
|
* @param data_size number of bytes in @a data
|
||||||
|
* @return the "code" value from @a json
|
||||||
|
*/
|
||||||
|
enum TALER_ErrorCode
|
||||||
|
TALER_JSON_get_error_code2 (const void *data,
|
||||||
|
size_t data_size);
|
||||||
|
|
||||||
|
|
||||||
/* **************** /wire account offline signing **************** */
|
/* **************** /wire account offline signing **************** */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,4 +80,33 @@ TALER_JSON_get_error_code (const json_t *json)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the Taler error code from the given @a data object, which is expected to be in JSON.
|
||||||
|
* Note that #TALER_EC_INVALID is returned if no "code" is present or if @a data is not in JSON.
|
||||||
|
*
|
||||||
|
* @param data response to extract the error code from
|
||||||
|
* @param data_size number of bytes in @a data
|
||||||
|
* @return the "code" value from @a json
|
||||||
|
*/
|
||||||
|
enum TALER_ErrorCode
|
||||||
|
TALER_JSON_get_error_code2 (const void *data,
|
||||||
|
size_t data_size)
|
||||||
|
{
|
||||||
|
json_t *json;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
json_error_t err;
|
||||||
|
|
||||||
|
json = json_loads (data,
|
||||||
|
data_size,
|
||||||
|
&err);
|
||||||
|
if (NULL == json)
|
||||||
|
return TALER_EC_INVALID;
|
||||||
|
ec = TALER_JSON_get_error_code (json);
|
||||||
|
json_decref (json);
|
||||||
|
if (ec == TALER_EC_NONE)
|
||||||
|
return TALER_EC_INVALID;
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* End of json/json.c */
|
/* End of json/json.c */
|
||||||
|
@ -35,7 +35,6 @@ TEL_curl_easy_get (const char *url)
|
|||||||
CURL *eh;
|
CURL *eh;
|
||||||
|
|
||||||
eh = curl_easy_init ();
|
eh = curl_easy_init ();
|
||||||
|
|
||||||
GNUNET_assert (CURLE_OK ==
|
GNUNET_assert (CURLE_OK ==
|
||||||
curl_easy_setopt (eh,
|
curl_easy_setopt (eh,
|
||||||
CURLOPT_URL,
|
CURLOPT_URL,
|
||||||
|
Loading…
Reference in New Issue
Block a user