summaryrefslogtreecommitdiff
path: root/src/lib/auditor_api_exchanges.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-05 22:05:38 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-05 22:05:38 +0200
commitbf8c5982a2e79f0b5198a0033dd41e9702d093f9 (patch)
tree93b62feb9b7e24ae3d4f73b1a5f883a8fc368bfe /src/lib/auditor_api_exchanges.c
parent5059da7108fb2d65fc3844ffe695574c532f8dff (diff)
downloadexchange-bf8c5982a2e79f0b5198a0033dd41e9702d093f9.tar.gz
exchange-bf8c5982a2e79f0b5198a0033dd41e9702d093f9.tar.bz2
exchange-bf8c5982a2e79f0b5198a0033dd41e9702d093f9.zip
make exchange API more uniform in how information is returned
Diffstat (limited to 'src/lib/auditor_api_exchanges.c')
-rw-r--r--src/lib/auditor_api_exchanges.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/lib/auditor_api_exchanges.c b/src/lib/auditor_api_exchanges.c
index 4e23267f..83cbc4bb 100644
--- a/src/lib/auditor_api_exchanges.c
+++ b/src/lib/auditor_api_exchanges.c
@@ -89,13 +89,16 @@ handle_exchanges_finished (void *cls,
const json_t *ja;
unsigned int ja_len;
struct TALER_AUDITOR_ListExchangesHandle *leh = cls;
- enum TALER_ErrorCode ec;
+ struct TALER_AUDITOR_HttpResponse hr = {
+ .reply = json,
+ .http_status = (unsigned int) response_code
+ };
leh->job = NULL;
switch (response_code)
{
case 0:
- ec = TALER_EC_INVALID_RESPONSE;
+ hr.ec = TALER_EC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
ja = json_object_get (json,
@@ -104,8 +107,8 @@ handle_exchanges_finished (void *cls,
(! json_is_array (ja)) )
{
GNUNET_break (0);
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
@@ -113,8 +116,8 @@ handle_exchanges_finished (void *cls,
if (ja_len > MAX_EXCHANGES)
{
GNUNET_break (0);
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
- response_code = 0;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
{
@@ -138,54 +141,54 @@ handle_exchanges_finished (void *cls,
{
GNUNET_break_op (0);
ok = GNUNET_NO;
- ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.ec = TALER_EC_AUDITOR_EXCHANGES_REPLY_MALFORMED;
+ hr.http_status = 0;
break;
}
}
if (GNUNET_YES != ok)
break;
leh->cb (leh->cb_cls,
- response_code,
- TALER_EC_NONE,
+ &hr,
ja_len,
- ei,
- json);
+ ei);
TALER_AUDITOR_list_exchanges_cancel (leh);
return;
}
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the auditor is buggy
(or API version conflict); just pass JSON reply to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
happen, we should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
- ec = TALER_JSON_get_error_code (json);
+ hr.ec = TALER_JSON_get_error_code (json);
+ hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d\n",
(unsigned int) response_code,
- (int) ec);
- GNUNET_break (0);
- response_code = 0;
+ (int) hr.ec);
+ GNUNET_break_op (0);
break;
}
if (NULL != leh->cb)
leh->cb (leh->cb_cls,
- response_code,
- TALER_JSON_get_error_code (json),
+ &hr,
0,
- NULL,
- json);
+ NULL);
TALER_AUDITOR_list_exchanges_cancel (leh);
}