rename and move TALER_EXCHANGE_json_get_error_code to TALER_JSON_get_error_code

This commit is contained in:
Christian Grothoff 2016-10-20 21:19:01 +02:00
parent 63c5706b64
commit 19f4c50dab
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
14 changed files with 55 additions and 50 deletions

View File

@ -129,7 +129,7 @@ handle_admin_add_incoming_finished (void *cls,
}
aai->cb (aai->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
json);
TALER_EXCHANGE_admin_add_incoming_cancel (aai);
}

View File

@ -26,33 +26,6 @@
#include "taler_signatures.h"
/**
* Extract the Taler error code from the given @a json object.
* Note that #TALER_EC_NONE is returned if no "code" is present.
*
* @param json response to extract the error code from
* @return the "code" value from @a json
*/
enum TALER_ErrorCode
TALER_EXCHANGE_json_get_error_code (const json_t *json)
{
const json_t *jc;
if (NULL == json)
{
GNUNET_break_op (0);
return TALER_EC_INVALID_RESPONSE;
}
jc = json_object_get (json, "code");
if (NULL == jc)
return TALER_EC_NONE;
if (json_is_integer (jc))
return (enum TALER_ErrorCode) json_integer_value (jc);
GNUNET_break_op (0);
return TALER_EC_INVALID;
}
/**
* Verify a coins transaction history as returned by the exchange.
*

View File

@ -261,7 +261,7 @@ handle_deposit_finished (void *cls,
}
dh->cb (dh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
ep,
json);
TALER_EXCHANGE_deposit_cancel (dh);

View File

@ -1114,7 +1114,7 @@ handle_refresh_melt_finished (void *cls,
{
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
noreveal_index,
(0 == response_code) ? NULL : &exchange_pub,
json);
@ -1160,7 +1160,7 @@ handle_refresh_melt_finished (void *cls,
if (NULL != rmh->melt_cb)
rmh->melt_cb (rmh->melt_cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
UINT16_MAX,
NULL,
json);
@ -1636,7 +1636,7 @@ handle_refresh_reveal_finished (void *cls,
if (NULL != rrh->reveal_cb)
rrh->reveal_cb (rrh->reveal_cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
0,
NULL,
NULL,

View File

@ -346,7 +346,7 @@ handle_refresh_link_finished (void *cls,
if (NULL != rlh->link_cb)
rlh->link_cb (rlh->link_cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
0,
NULL,
NULL,

View File

@ -195,7 +195,7 @@ handle_refund_finished (void *cls,
}
rh->cb (rh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
ep,
json);
TALER_EXCHANGE_refund_cancel (rh);

View File

@ -389,7 +389,7 @@ handle_reserve_status_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
json,
NULL,
0, NULL);
@ -766,7 +766,7 @@ handle_reserve_withdraw_finished (void *cls,
if (NULL != wsh->cb)
wsh->cb (wsh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
NULL,
json);
TALER_EXCHANGE_reserve_withdraw_cancel (wsh);

View File

@ -238,7 +238,7 @@ handle_deposit_wtid_finished (void *cls,
}
dwh->cb (dwh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
ep,
json,
wtid,

View File

@ -253,7 +253,7 @@ handle_track_transfer_finished (void *cls,
}
wdh->cb (wdh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
NULL,
json,
NULL,

View File

@ -209,7 +209,7 @@ handle_wire_finished (void *cls,
}
wh->cb (wh->cb_cls,
response_code,
TALER_EXCHANGE_json_get_error_code (json),
TALER_JSON_get_error_code (json),
(NULL != keep) ? keep : json);
if (NULL != keep)
json_decref (keep);

View File

@ -1263,15 +1263,4 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
struct TALER_Amount *total);
/**
* Extract the Taler error code from the given @a json object.
* Note that #TALER_EC_NONE is returned if no "code" is present.
*
* @param json response to extract the error code from
* @return the "code" value from @a json
*/
enum TALER_ErrorCode
TALER_EXCHANGE_json_get_error_code (const json_t *json);
#endif /* _TALER_EXCHANGE_SERVICE_H */

View File

@ -25,6 +25,7 @@
#include <jansson.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_util.h"
#include "taler_error_codes.h"
/**
* Print JSON parsing related error information
@ -92,6 +93,17 @@ int
TALER_JSON_hash (const json_t *json,
struct GNUNET_HashCode *hc);
/**
* Extract the Taler error code from the given @a json object.
* Note that #TALER_EC_NONE is returned if no "code" is present.
*
* @param json response to extract the error code from
* @return the "code" value from @a json
*/
enum TALER_ErrorCode
TALER_JSON_get_error_code (const json_t *json);
#endif /* TALER_JSON_LIB_H_ */
/* End of taler_json_lib.h */

View File

@ -117,4 +117,6 @@ const struct GNUNET_OS_ProjectData *
TALER_project_data_default (void);
#endif

View File

@ -50,4 +50,33 @@ TALER_JSON_hash (const json_t *json,
}
/**
* Extract the Taler error code from the given @a json object.
* Note that #TALER_EC_NONE is returned if no "code" is present.
*
* @param json response to extract the error code from
* @return the "code" value from @a json
*/
enum TALER_ErrorCode
TALER_JSON_get_error_code (const json_t *json)
{
const json_t *jc;
if (NULL == json)
{
GNUNET_break_op (0);
return TALER_EC_INVALID_RESPONSE;
}
jc = json_object_get (json, "code");
if (NULL == jc)
return TALER_EC_NONE;
if (json_is_integer (jc))
return (enum TALER_ErrorCode) json_integer_value (jc);
GNUNET_break_op (0);
return TALER_EC_INVALID;
}
/* End of json/json.c */