rename and move TALER_EXCHANGE_json_get_error_code to TALER_JSON_get_error_code
This commit is contained in:
parent
63c5706b64
commit
19f4c50dab
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -117,4 +117,6 @@ const struct GNUNET_OS_ProjectData *
|
||||
TALER_project_data_default (void);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user