[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add another helper
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add another helper |
Date: |
Mon, 25 Nov 2019 01:42:58 +0100 |
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 70a210ac add another helper
70a210ac is described below
commit 70a210ac4db07a28867e23db13c68aecc117810a
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Nov 25 01:42:55 2019 +0100
add another helper
---
src/include/taler_json_lib.h | 13 +++++++++++++
src/json/json.c | 29 +++++++++++++++++++++++++++++
src/lib/exchange_api_curl_defaults.c | 1 -
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 382bb19e..6adb76b2 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -126,6 +126,19 @@ enum TALER_ErrorCode
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 **************** */
/**
diff --git a/src/json/json.c b/src/json/json.c
index 90fe3dd4..8d408979 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -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 */
diff --git a/src/lib/exchange_api_curl_defaults.c
b/src/lib/exchange_api_curl_defaults.c
index 36d1edf7..7b642bc8 100644
--- a/src/lib/exchange_api_curl_defaults.c
+++ b/src/lib/exchange_api_curl_defaults.c
@@ -35,7 +35,6 @@ TEL_curl_easy_get (const char *url)
CURL *eh;
eh = curl_easy_init ();
-
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_URL,
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add another helper,
gnunet <=