aboutsummaryrefslogtreecommitdiff
path: root/src/json/json.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-11-07 14:39:15 +0100
committerChristian Grothoff <christian@grothoff.org>2016-11-07 14:39:15 +0100
commit1d740824fa8914e21c402abefc5f3d5a8cdfa4ca (patch)
tree74223d7b8931806183f5b5d8b09222c00d8a62c7 /src/json/json.c
parent6d6a9dac39bd6c24a7d527186aaa2a1eec2d8c36 (diff)
parent247b8e33b3ea20407910929c78232ff0d44e8d9a (diff)
resolving merge issue
Diffstat (limited to 'src/json/json.c')
-rw-r--r--src/json/json.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/json/json.c b/src/json/json.c
index 8f21447e..74559e6c 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -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 */