aboutsummaryrefslogtreecommitdiff
path: root/src/wire/plugin_wire_test.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-01 08:37:44 +0200
committerChristian Grothoff <christian@grothoff.org>2016-04-01 08:37:44 +0200
commit92907bee45681b1273172a3c88461a60bcae8589 (patch)
tree9b3c16f849974abe3107521d16bf0e723ef5199d /src/wire/plugin_wire_test.c
parent3a2e547da9cc5669a73e10ec30e67dac3016a24d (diff)
return nicer error message from bank API and fix compiler warning
Diffstat (limited to 'src/wire/plugin_wire_test.c')
-rw-r--r--src/wire/plugin_wire_test.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 70cf82462..3ef76aa6b 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -419,22 +419,40 @@ test_prepare_wire_transfer_cancel (void *cls,
* @param cls closure with the `struct TALER_WIRE_ExecuteHandle`
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the bank's reply is bogus (fails to follow the protocol)
+ * @param json detailed response from the HTTPD, or NULL if reply was not JSON
*/
static void
execute_cb (void *cls,
- unsigned int http_status)
+ unsigned int http_status,
+ json_t *json)
{
struct TALER_WIRE_ExecuteHandle *eh = cls;
- char s[14];
+ json_t *reason;
+ const char *emsg;
+ char *s;
eh->aaih = NULL;
- GNUNET_snprintf (s,
- sizeof (s),
- "%u",
- http_status);
+ emsg = NULL;
+ if (NULL != json)
+ {
+ reason = json_object_get (json,
+ "reason");
+ if (NULL != reason)
+ emsg = json_string_value (reason);
+ }
+ if (NULL != emsg)
+ GNUNET_asprintf (&s,
+ "%u (%s)",
+ http_status,
+ emsg);
+ else
+ GNUNET_asprintf (&s,
+ "%u",
+ http_status);
eh->cc (eh->cc_cls,
(MHD_HTTP_OK == http_status) ? GNUNET_OK : GNUNET_SYSERR,
(MHD_HTTP_OK == http_status) ? NULL : s);
+ GNUNET_free (s);
GNUNET_free (eh);
}