[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: introduce TALER_JSON_pack_ec
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: introduce TALER_JSON_pack_ec |
Date: |
Sun, 01 Aug 2021 15:36:40 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new d45774cc introduce TALER_JSON_pack_ec
d45774cc is described below
commit d45774ccecaed85f45c2eebe641e2d2f8c8673af
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 1 15:36:38 2021 +0200
introduce TALER_JSON_pack_ec
---
src/exchange/taler-exchange-httpd_melt.c | 6 +-----
src/exchange/taler-exchange-httpd_refreshes_reveal.c | 7 ++-----
src/exchange/taler-exchange-httpd_refund.c | 13 +++----------
src/exchange/taler-exchange-httpd_responses.c | 11 +++--------
src/exchange/taler-exchange-httpd_withdraw.c | 6 +-----
src/include/taler_json_lib.h | 10 ++++++++++
6 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_melt.c
b/src/exchange/taler-exchange-httpd_melt.c
index 42780826..071a9c38 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -69,11 +69,7 @@ reply_melt_insufficient_funds (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_CONFLICT,
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
- TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS)),
- GNUNET_JSON_pack_uint64 ("code",
- TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS),
+ TALER_JSON_pack_ec (TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub),
TALER_JSON_pack_amount ("original_value",
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 5cbb6e6c..2a5c3aca 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -387,11 +387,8 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_CONFLICT,
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
-
TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION)),
- GNUNET_JSON_pack_uint64 ("code",
-
TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION),
+ TALER_JSON_pack_ec (
+ TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION),
GNUNET_JSON_pack_data_auto ("rc_expected",
&rc_expected));
return GNUNET_DB_STATUS_HARD_ERROR;
diff --git a/src/exchange/taler-exchange-httpd_refund.c
b/src/exchange/taler-exchange-httpd_refund.c
index c2b2d800..2ea19b7e 100644
--- a/src/exchange/taler-exchange-httpd_refund.c
+++ b/src/exchange/taler-exchange-httpd_refund.c
@@ -233,11 +233,7 @@ refund_transaction (void *cls,
MHD_HTTP_PRECONDITION_FAILED,
TALER_JSON_pack_amount ("detail",
&ref->refund_amount),
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
-
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT)),
- GNUNET_JSON_pack_uint64 ("code",
-
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT),
+ TALER_JSON_pack_ec (TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT),
GNUNET_JSON_pack_array_steal ("history",
TEH_RESPONSE_compile_transaction_history (
&refund->coin.coin_pub,
@@ -332,11 +328,8 @@ refund_transaction (void *cls,
MHD_HTTP_CONFLICT,
GNUNET_JSON_pack_string ("detail",
"total amount refunded exceeds total amount
deposited for this coin"),
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
-
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT)),
- GNUNET_JSON_pack_uint64 ("code",
-
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
+ TALER_JSON_pack_ec (
+ TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
GNUNET_JSON_pack_array_steal ("history",
TEH_RESPONSE_compile_transaction_history (
&refund->coin.coin_pub,
diff --git a/src/exchange/taler-exchange-httpd_responses.c
b/src/exchange/taler-exchange-httpd_responses.c
index e05b537e..72d1ddb7 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -450,8 +450,7 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_NOT_FOUND,
- GNUNET_JSON_pack_uint64 ("code",
-
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN),
+ TALER_JSON_pack_ec (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN),
GNUNET_JSON_pack_time_abs ("timestamp",
now),
GNUNET_JSON_pack_data_auto ("exchange_pub",
@@ -501,8 +500,7 @@ TEH_RESPONSE_reply_expired_denom_pub_hash (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_GONE,
- GNUNET_JSON_pack_uint64 ("code",
- ec),
+ TALER_JSON_pack_ec (ec),
GNUNET_JSON_pack_string ("oper",
oper),
GNUNET_JSON_pack_time_abs ("timestamp",
@@ -550,10 +548,7 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_CONFLICT,
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (ec)),
- GNUNET_JSON_pack_uint64 ("code",
- ec),
+ TALER_JSON_pack_ec (ec),
GNUNET_JSON_pack_array_steal ("history",
history));
}
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c
b/src/exchange/taler-exchange-httpd_withdraw.c
index a5e6db0a..7be56084 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -81,11 +81,7 @@ reply_withdraw_insufficient_funds (
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_CONFLICT,
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
- TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS)),
- GNUNET_JSON_pack_uint64 ("code",
- TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS),
+ TALER_JSON_pack_ec (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS),
TALER_JSON_pack_amount ("balance",
&balance),
GNUNET_JSON_pack_array_steal ("history",
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index f338d44a..ea621cea 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -79,6 +79,16 @@ TALER_JSON_pack_time_abs_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO at);
+/**
+ * Put an error code into a JSON reply, including
+ * both the numeric value and the hint.
+ *
+ * @param ec error code to encode using canonical field names
+ */
+#define TALER_JSON_pack_ec(ec) \
+ GNUNET_JSON_pack_string ("hint", TALER_ErrorCode_get_hint (ec)), \
+ GNUNET_JSON_pack_uint64 ("code", ec)
+
/**
* Generate packer instruction for a JSON field of type
* absolute time creating a human-readable timestamp.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: introduce TALER_JSON_pack_ec,
gnunet <=