From 6e3765d85253867fcc8cb6409ac65d0dd637c479 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 10 Mar 2020 18:51:08 +0100 Subject: more careful use of TALER_JSON_get_error_code(), limit to cases where we expect to get one --- src/lib/auditor_api_deposit_confirmation.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/lib/auditor_api_deposit_confirmation.c') diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index ddaf9b7cd..0aa9ff731 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -87,43 +87,52 @@ handle_deposit_confirmation_finished (void *cls, { const json_t *json = djson; struct TALER_AUDITOR_DepositConfirmationHandle *dh = cls; + enum TALER_ErrorCode ec; dh->job = NULL; switch (response_code) { case 0: + ec = TALER_EC_INVALID_RESPONSE; break; case MHD_HTTP_OK: + ec = TALER_EC_NONE; break; case MHD_HTTP_BAD_REQUEST: + ec = TALER_JSON_get_error_code (json); /* This should never happen, either us or the auditor is buggy (or API version conflict); just pass JSON reply to the application */ break; case MHD_HTTP_FORBIDDEN: + ec = TALER_JSON_get_error_code (json); /* Nothing really to verify, auditor says one of the signatures is invalid; as we checked them, this should never happen, we should pass the JSON reply to the application */ break; case MHD_HTTP_NOT_FOUND: + ec = TALER_JSON_get_error_code (json); /* Nothing really to verify, this should never happen, we should pass the JSON reply to the application */ break; case MHD_HTTP_INTERNAL_SERVER_ERROR: + ec = TALER_JSON_get_error_code (json); /* Server had an internal issue; we should retry, but this API leaves this to the application */ break; default: /* unexpected response code */ + ec = TALER_JSON_get_error_code (json); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u\n", - (unsigned int) response_code); + "Unexpected response code %u/%d\n", + (unsigned int) response_code, + ec); GNUNET_break (0); response_code = 0; break; } dh->cb (dh->cb_cls, response_code, - TALER_JSON_get_error_code (json), + ec, json); TALER_AUDITOR_deposit_confirmation_cancel (dh); } -- cgit v1.2.3