diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-11-08 00:50:16 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-11-08 00:50:16 +0100 |
commit | e42cf1a738aef2c2aee32997d157965b02e2fe0d (patch) | |
tree | 0332ba70640210f1e4119927e2e5b72005f57163 /src/backend | |
parent | 579938a29e1d1d4ada49ca4c1a8b0d18878974a9 (diff) | |
download | merchant-e42cf1a738aef2c2aee32997d157965b02e2fe0d.tar.gz merchant-e42cf1a738aef2c2aee32997d157965b02e2fe0d.tar.bz2 merchant-e42cf1a738aef2c2aee32997d157965b02e2fe0d.zip |
adjust error codes in merchant
Diffstat (limited to 'src/backend')
37 files changed, 627 insertions, 467 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 0ae3b4ce..1dcc51c8 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -1547,12 +1547,12 @@ url_handler (void *cls, (url_found) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_METHOD_NOT_ALLOWED, - TALER_EC_METHOD_INVALID, + TALER_EC_GENERIC_METHOD_INVALID, method); if (NULL == hc->rh) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_ENDPOINT_UNKNOWN, + TALER_EC_GENERIC_ENDPOINT_UNKNOWN, hc->url); } } @@ -1562,7 +1562,7 @@ url_handler (void *cls, (GNUNET_YES != hc->rh->skip_instance) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_INSTANCE_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN, url); hc->has_body = ( (0 == strcasecmp (method, MHD_HTTP_METHOD_POST)) || @@ -1597,7 +1597,7 @@ url_handler (void *cls, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_PAYLOAD_TOO_LARGE, - TALER_EC_UPLOAD_EXCEEDS_LIMIT, + TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT, cl); } } diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c index c7e7e584..179fa320 100644 --- a/src/backend/taler-merchant-httpd_auditors.c +++ b/src/backend/taler-merchant-httpd_auditors.c @@ -76,7 +76,7 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Denomination key offered by client has expired for deposits\n"); *hc = MHD_HTTP_GONE; - *ec = TALER_EC_PAY_DENOMINATION_DEPOSIT_EXPIRED; + *ec = TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_DEPOSIT_EXPIRED; return GNUNET_SYSERR; /* expired */ } if (exchange_trusted) @@ -90,8 +90,9 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, { /* this should never happen, keys should have been successfully obtained before we even got into this function */ - *ec = TALER_EC_PAY_EXCHANGE_HAS_NO_KEYS; - *hc = MHD_HTTP_FAILED_DEPENDENCY; + GNUNET_break (0); + *ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; + *hc = MHD_HTTP_INTERNAL_SERVER_ERROR; return GNUNET_SYSERR; } for (unsigned int i = 0; i<keys->num_auditors; i++) @@ -120,7 +121,7 @@ TMH_AUDITORS_check_dk (struct TALER_EXCHANGE_Handle *mh, "Denomination key %s offered by client not audited by any accepted auditor\n", GNUNET_h2s (&dk->h_key)); *hc = MHD_HTTP_BAD_REQUEST; - *ec = TALER_EC_PAY_DENOMINATION_KEY_AUDITOR_FAILURE; + *ec = TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_AUDITOR_FAILURE; return GNUNET_NO; } diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index e882f557..2c8995ee 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -372,7 +372,7 @@ process_wire_fees (struct Exchange *exchange, { /* Hole in the fee structure, not allowed! */ GNUNET_break_op (0); - return TALER_EC_HOLE_IN_WIRE_FEE_STRUCTURE; + return TALER_EC_MERCHANT_GENERIC_HOLE_IN_WIRE_FEE_STRUCTURE; } while (NULL != fees) { @@ -477,7 +477,7 @@ process_wire_accounts (struct Exchange *exchange, { /* malformed payto:// URI returned by exchange */ GNUNET_break_op (0); - return TALER_EC_PAYTO_MALFORMED; + return TALER_EC_GENERIC_PAYTO_URI_MALFORMED; } ec = process_wire_fees (exchange, master_pub, diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index 5c6949bb..c0922f67 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -694,7 +694,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "token"); } } @@ -714,7 +714,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "h_contract"); } } @@ -738,7 +738,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "timeout_ms (must be non-negative number)"); } god->sc.long_poll_timeout @@ -783,7 +783,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "refund"); } god->sc.awaiting_refund = true; @@ -815,8 +815,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms"); } } @@ -834,8 +834,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_free (god); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, - "could not hash contract terms"); + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, + "contract terms"); } contract_match = (0 == GNUNET_memcmp (&h, @@ -845,10 +845,11 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, (! contract_match) ) { GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_GET_ORDER_WRONG_CONTRACT, - NULL); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER, + NULL); } } @@ -874,8 +875,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order"); } god->unclaimed = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) && ! contract_available; @@ -887,7 +888,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, order_id); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_GET_ORDERS_ID_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, order_id); } token_match = (0 == GNUNET_memcmp (&db_claim_token, @@ -901,7 +902,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_CONTRACT_CONTENT_INVALID, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, order_id); } @@ -921,7 +922,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, - TALER_EC_MERCHANT_GET_ORDER_INVALID_TOKEN, + TALER_EC_MERCHANT_GET_ORDERS_ID_INVALID_TOKEN, NULL); } if ( ( (! token_match) || @@ -932,13 +933,14 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { if (GNUNET_NO == GNUNET_is_zero (&god->h_contract_terms)) - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_GET_ORDER_WRONG_CONTRACT, - NULL); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER, + NULL); return TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, - TALER_EC_MERCHANT_GET_ORDER_INVALID_TOKEN, + TALER_EC_MERCHANT_GET_ORDERS_ID_INVALID_TOKEN, NULL); } if (god->generate_html) @@ -1014,8 +1016,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order by fulfillment"); } if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) || (0 != strcmp (order_id, @@ -1052,8 +1054,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order status"); } GNUNET_break (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); GNUNET_break (0 == @@ -1084,8 +1086,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "refunds, detailed"); } if ( ((god->sc.awaiting_refund) && @@ -1134,7 +1136,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (god->sc.con, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ALLOCATION_FAILURE, + TALER_EC_GENERIC_ALLOCATION_FAILURE, "refund URI"); } qr = TMH_create_qrcode (uri); @@ -1144,7 +1146,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_free (uri); return TALER_MHD_reply_with_error (god->sc.con, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ALLOCATION_FAILURE, + TALER_EC_GENERIC_ALLOCATION_FAILURE, "qr code"); } { diff --git a/src/backend/taler-merchant-httpd_get-tips-ID.c b/src/backend/taler-merchant-httpd_get-tips-ID.c index 5fa257fc..fd60c6e9 100644 --- a/src/backend/taler-merchant-httpd_get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_get-tips-ID.c @@ -171,7 +171,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, hc->infix); } @@ -193,7 +193,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_TIPS_DB_LOOKUP_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, NULL); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -203,7 +203,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, hc->infix); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_GET_TIPS_ID_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN, hc->infix); } @@ -238,7 +238,7 @@ TMH_get_tips_ID (const struct TMH_RequestHandler *rh, GNUNET_free (uri); ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ALLOCATION_FAILURE, + TALER_EC_GENERIC_ALLOCATION_FAILURE, "during QR code generation"); } else diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c index cfb5bb72..4f6b8667 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c @@ -32,8 +32,9 @@ /** * How long to wait before giving up processing with the exchange? */ -#define ABORT_TIMEOUT (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - 30)) +#define ABORT_GENERIC_TIMEOUT (GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_UNIT_SECONDS, \ + 30)) /** * How often do we retry the (complex!) database transaction? @@ -349,7 +350,7 @@ generate_success_response (struct AbortContext *ac) GNUNET_break (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_JSON_ALLOCATION_FAILURE, + TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, "could not create JSON array"); return; } @@ -386,7 +387,7 @@ generate_success_response (struct AbortContext *ac) GNUNET_break (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_JSON_ALLOCATION_FAILURE, + TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, "could not create JSON array"); return; } @@ -518,27 +519,35 @@ process_abort_with_exchange (void *cls, (void) exchange_trusted; ac->fo = NULL; GNUNET_assert (GNUNET_YES == ac->suspended); - if (MHD_HTTP_OK != hr->http_status) + if (NULL == hr) { - /* The request failed somehow */ - GNUNET_break_op (0); resume_abort_with_response ( ac, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_GATEWAY_TIMEOUT, TALER_MHD_make_json_pack ( - (NULL != hr->reply) - ? "{s:s, s:I, s:I, s:I, s:O}" - : "{s:s, s:I, s:I, s:I}", + "{s:s, s:I}", "hint", - TALER_ErrorCode_get_hint (TALER_EC_ABORT_EXCHANGE_KEYS_FAILURE), + TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT), "code", - (json_int_t) TALER_EC_ABORT_EXCHANGE_KEYS_FAILURE, - "exchange_http_status", - (json_int_t) hr->http_status, - "exchange_code", - (json_int_t) hr->ec, - "exchange_reply", - hr->reply)); + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); + return; + } + if (NULL == exchange_handle) + { + /* The request failed somehow */ + GNUNET_break_op (0); + resume_abort_with_response ( + ac, + MHD_HTTP_BAD_GATEWAY, + TALER_MHD_make_json_pack ( + "{s:s, s:I, s:I, s:I, s:O?}", + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, + "exchange_http_status", (json_int_t) hr->http_status, + "exchange_code", (json_int_t) hr->ec, + "exchange_reply", hr->reply)); return; } /* Initiate refund operation for all coins of @@ -569,7 +578,7 @@ process_abort_with_exchange (void *cls, GNUNET_break_op (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_EXCHANGE_REFUND_FAILED, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_REFUND_FAILED, "Failed to start refund with exchange"); return; } @@ -615,7 +624,7 @@ find_next_exchange (struct AbortContext *ac) GNUNET_break (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_EXCHANGE_LOOKUP_FAILED, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_EXCHANGE_LOOKUP_FAILED, "Failed to lookup exchange by URL"); return; } @@ -691,8 +700,8 @@ refund_coins (void *cls, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_STORE_ABORT_ERROR, - "Merchant database error storing abort-refund"); + TALER_EC_GENERIC_DB_STORE_FAILED, + "refund_coin"); return; } } /* for all coins */ @@ -716,8 +725,8 @@ begin_transaction (struct AbortContext *ac) GNUNET_break (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_STORE_TRANSACTION_ERROR, - "Soft merchant database error: retry counter exceeded"); + TALER_EC_GENERIC_DB_SOFT_FAILURE, + NULL); return; } GNUNET_assert (GNUNET_YES == ac->suspended); @@ -731,8 +740,8 @@ begin_transaction (struct AbortContext *ac) GNUNET_break (0); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error (could not begin transaction)"); + TALER_EC_GENERIC_DB_START_FAILED, + NULL); return; } @@ -763,14 +772,14 @@ begin_transaction (struct AbortContext *ac) GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error"); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order status"); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: TMH_db->rollback (TMH_db->cls); resume_abort_with_error (ac, MHD_HTTP_NOT_FOUND, - TALER_EC_ABORT_CONTRACT_NOT_FOUND, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_NOT_FOUND, "Could not find contract"); return; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: @@ -780,7 +789,7 @@ begin_transaction (struct AbortContext *ac) TMH_db->rollback (TMH_db->cls); resume_abort_with_error (ac, MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_REFUND_REFUSED_PAYMENT_COMPLETE, "Payment was complete, refusing to abort"); return; } @@ -792,7 +801,7 @@ begin_transaction (struct AbortContext *ac) GNUNET_break_op (0); resume_abort_with_error (ac, MHD_HTTP_FORBIDDEN, - TALER_EC_ABORT_CONTRACT_HASH_MISSMATCH, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_HASH_MISSMATCH, "Provided hash does not match order on file"); return; } @@ -816,8 +825,8 @@ begin_transaction (struct AbortContext *ac) GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error"); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "deposits"); return; } @@ -832,8 +841,8 @@ begin_transaction (struct AbortContext *ac) } resume_abort_with_error (ac, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ABORT_DB_STORE_ABORT_ERROR, - "Merchant database error: could not commit"); + TALER_EC_GENERIC_DB_COMMIT_FAILED, + NULL); return; } @@ -889,7 +898,7 @@ parse_abort (struct MHD_Connection *connection, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_ABORT_COINS_ARRAY_EMPTY, + TALER_EC_MERCHANT_POST_ORDERS_ID_ABORT_COINS_ARRAY_EMPTY, "coins"); } /* note: 1 coin = 1 deposit confirmation expected */ @@ -957,9 +966,9 @@ handle_abort_timeout (void *cls) ac->fo = NULL; } resume_abort_with_error (ac, - MHD_HTTP_REQUEST_TIMEOUT, - TALER_EC_ABORT_EXCHANGE_TIMEOUT, - "likely the exchange did not reply quickly enough"); + MHD_HTTP_GATEWAY_TIMEOUT, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, + NULL); } @@ -1023,7 +1032,7 @@ TMH_post_orders_ID_abort (const struct TMH_RequestHandler *rh, ac->suspended = GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending abort handling while working with the exchange\n"); - ac->timeout_task = GNUNET_SCHEDULER_add_delayed (ABORT_TIMEOUT, + ac->timeout_task = GNUNET_SCHEDULER_add_delayed (ABORT_GENERIC_TIMEOUT, &handle_abort_timeout, ac); begin_transaction (ac); diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c index 5580fb20..f82ed061 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c @@ -201,24 +201,24 @@ TMH_post_orders_ID_claim (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_CLAIM_HARD_DB_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_CLAIM_SOFT_DB_ERROR, + TALER_EC_GENERIC_DB_SOFT_FAILURE, NULL); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: if (NULL == contract_terms) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_ORDERS_CLAIM_NOT_FOUND, + TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_NOT_FOUND, order_id); /* already claimed! */ json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_ORDERS_ALREADY_CLAIMED, + TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_ALREADY_CLAIMED, order_id); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: GNUNET_assert (NULL != contract_terms); @@ -240,7 +240,7 @@ TMH_post_orders_ID_claim (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, NULL); } diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c index effc4e12..1e692bfc 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-paid.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-paid.c @@ -77,7 +77,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_FORBIDDEN, - TALER_EC_PAID_COIN_SIGNATURE_INVALID, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAID_COIN_SIGNATURE_INVALID, NULL); } @@ -100,8 +100,8 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAID_DB_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms"); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { @@ -110,7 +110,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, order_id); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PAID_ORDER_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, order_id); } @@ -125,8 +125,8 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, - "Could not hash contract terms"); + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, + NULL); } if (0 != GNUNET_memcmp (&pr.h_contract_terms, &h_contract_terms)) @@ -134,7 +134,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_PAID_CONTRACT_HASH_MISMATCH, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAID_CONTRACT_HASH_MISMATCH, NULL); } } @@ -147,7 +147,7 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAID_DB_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } { @@ -179,8 +179,8 @@ TMH_post_orders_ID_paid (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAID_DB_ERROR, - NULL); + TALER_EC_GENERIC_DB_STORE_FAILED, + "mark contract paid"); } } if (NULL != session_id) diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c index 0e033a7f..93835a24 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c @@ -594,14 +594,15 @@ deposit_cb (void *cls, { /* internal server error at exchange */ resume_pay_with_response (pc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_BAD_GATEWAY, TALER_MHD_make_json_pack ( "{s:s, s:I, s:I, s:I}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_EXCHANGE_FAILED), + TALER_EC_MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS), "code", - (json_int_t) TALER_EC_PAY_EXCHANGE_FAILED, + (json_int_t) + TALER_EC_MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", @@ -612,14 +613,14 @@ deposit_cb (void *cls, /* We can't do anything meaningful here, the exchange did something wrong */ resume_pay_with_response ( pc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_BAD_GATEWAY, TALER_MHD_make_json_pack ( "{s:s, s:I, s:I, s:I}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_EXCHANGE_REPLY_MALFORMED), + TALER_EC_MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED), "code", - (json_int_t) TALER_EC_PAY_EXCHANGE_REPLY_MALFORMED, + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_REPLY_MALFORMED, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", @@ -629,16 +630,17 @@ deposit_cb (void *cls, { /* Forward error, adding the "coin_pub" for which the error was being generated */ - if (TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS == hr->ec) + if (TALER_EC_EXCHANGE_DEPOSIT_INSUFFICIENT_FUNDS == hr->ec) resume_pay_with_response ( pc, MHD_HTTP_CONFLICT, TALER_MHD_make_json_pack ("{s:s, s:I, s:I, s:I, s:o, s:O}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_INSUFFICIENT_FUNDS), + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS), "code", - (json_int_t) TALER_EC_PAY_INSUFFICIENT_FUNDS, + (json_int_t) + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_FUNDS, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", @@ -650,13 +652,14 @@ deposit_cb (void *cls, else resume_pay_with_response ( pc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_BAD_GATEWAY, TALER_MHD_make_json_pack ("{s:s, s:I, s:I, s:I, s:o, s:O}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_EXCHANGE_FAILED), + TALER_EC_MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS), "code", - (json_int_t) TALER_EC_PAY_EXCHANGE_FAILED, + (json_int_t) + TALER_EC_MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", @@ -703,8 +706,8 @@ deposit_cb (void *cls, /* Forward error including 'proof' for the body */ resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_STORE_PAY_ERROR, - "Merchant database error"); + TALER_EC_GENERIC_DB_STORE_FAILED, + "deposit"); return; } dc->found_in_db = true; /* well, at least NOW it'd be true ;-) */ @@ -743,28 +746,34 @@ process_pay_with_exchange (void *cls, (void) payto_uri; pc->fo = NULL; GNUNET_assert (GNUNET_YES == pc->suspended); - if (MHD_HTTP_OK != hr->http_status) + if (NULL == hr) { - /* The request failed somehow */ - GNUNET_break_op (0); resume_pay_with_response ( pc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_GATEWAY_TIMEOUT, TALER_MHD_make_json_pack ( - (NULL != hr->reply) - ? "{s:s, s:I, s:I, s:I, s:O}" - : "{s:s, s:I, s:I, s:I}", + "{s:s, s:I}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_EXCHANGE_KEYS_FAILURE), + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT), "code", - (json_int_t) TALER_EC_PAY_EXCHANGE_KEYS_FAILURE, - "exchange_http_status", - (json_int_t) hr->http_status, - "exchange_code", - (json_int_t) hr->ec, - "exchange_reply", - hr->reply)); + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); + return; + } + if (NULL == exchange_handle) + { + GNUNET_break_op (0); + resume_pay_with_response ( + pc, + MHD_HTTP_BAD_GATEWAY, + TALER_MHD_make_json_pack ( + "{s:s, s:I, s:I, s:I, s:O?}", + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, + "exchange_http_status", (json_int_t) hr->http_status, + "exchange_code", (json_int_t) hr->ec, + "exchange_reply", hr->reply)); return; } keys = TALER_EXCHANGE_get_keys (exchange_handle); @@ -772,9 +781,9 @@ process_pay_with_exchange (void *cls, { GNUNET_break (0); /* should not be possible if HTTP status is #MHD_HTTP_OK */ resume_pay_with_error (pc, - MHD_HTTP_FAILED_DEPENDENCY, - TALER_EC_PAY_EXCHANGE_KEYS_FAILURE, - "no keys"); + MHD_HTTP_BAD_GATEWAY, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE, + NULL); return; } @@ -822,8 +831,9 @@ process_pay_with_exchange (void *cls, "{s:s, s:I, s:o, s:o}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_PAY_DENOMINATION_KEY_NOT_FOUND), - "code", TALER_EC_PAY_DENOMINATION_KEY_NOT_FOUND, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND), + "code", + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_DENOMINATION_KEY_NOT_FOUND, "h_denom_pub", GNUNET_JSON_from_data_auto (&dc->h_denom), "exchange_keys", TALER_EXCHANGE_get_keys_raw (exchange_handle))); return; @@ -881,8 +891,11 @@ process_pay_with_exchange (void *cls, TALER_MHD_make_json_pack ( "{s:s, s:I, s:i}", "hint", - TALER_ErrorCode_get_hint (TALER_EC_PAY_COIN_SIGNATURE_INVALID), - "code", (json_int_t) TALER_EC_PAY_COIN_SIGNATURE_INVALID, + TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_COIN_SIGNATURE_INVALID), + "code", + (json_int_t) + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_COIN_SIGNATURE_INVALID, "coin_idx", i)); return; } @@ -920,7 +933,7 @@ find_next_exchange (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_EXCHANGE_LOOKUP_FAILED, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_LOOKUP_FAILED, "Failed to lookup exchange by URL"); return; } @@ -1070,7 +1083,7 @@ check_payment_sufficient (struct PayContext *pc) /* Overflow in these amounts? Very strange. */ resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_AMOUNT_OVERFLOW, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_AMOUNT_OVERFLOW, "Overflow adding up amounts"); } if (1 == @@ -1080,7 +1093,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break_op (0); resume_pay_with_error (pc, MHD_HTTP_BAD_REQUEST, - TALER_EC_PAY_FEES_EXCEED_PAYMENT, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_FEES_EXCEED_PAYMENT, "Deposit fees exceed coin's contribution"); return false; } @@ -1105,8 +1118,8 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break_op (0); resume_pay_with_error (pc, MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_PAY_WIRE_FEE_CURRENCY_MISMATCH, - "exchange wire in different currency"); + TALER_EC_GENERIC_CURRENCY_MISMATCH, + total_wire_fee.currency); return false; } if (0 > @@ -1117,7 +1130,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_EXCHANGE_WIRE_FEE_ADDITION_FAILED, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_EXCHANGE_WIRE_FEE_ADDITION_FAILED, "could not add exchange wire fee to total"); return false; } @@ -1152,8 +1165,8 @@ check_payment_sufficient (struct PayContext *pc) { resume_pay_with_error (pc, MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_PAY_WIRE_FEE_CURRENCY_MISMATCH, - "exchange wire does not match our currency"); + TALER_EC_GENERIC_CURRENCY_MISMATCH, + total_wire_fee.currency); return false; } @@ -1189,7 +1202,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_AMOUNT_OVERFLOW, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_AMOUNT_OVERFLOW, "Overflow adding up amounts"); return false; } @@ -1217,7 +1230,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_AMOUNT_OVERFLOW, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_AMOUNT_OVERFLOW, "Overflow adding up amounts"); return false; } @@ -1241,7 +1254,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_REFUNDS_EXCEED_PAYMENTS, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_REFUNDS_EXCEED_PAYMENTS, "refunded amount exceeds total payments"); return false; } @@ -1255,7 +1268,7 @@ check_payment_sufficient (struct PayContext *pc) { resume_pay_with_error (pc, MHD_HTTP_PAYMENT_REQUIRED, - TALER_EC_PAY_REFUNDED, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_REFUNDED, "contract not paid up due to refunds"); } else if (-1 < TALER_amount_cmp (&acc_amount, @@ -1264,7 +1277,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break_op (0); resume_pay_with_error (pc, MHD_HTTP_NOT_ACCEPTABLE, - TALER_EC_PAY_PAYMENT_INSUFFICIENT_DUE_TO_FEES, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_INSUFFICIENT_DUE_TO_FEES, "contract not paid up due to fees (client may have calculated them badly)"); } else @@ -1272,7 +1285,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_break_op (0); resume_pay_with_error (pc, MHD_HTTP_NOT_ACCEPTABLE, - TALER_EC_PAY_PAYMENT_INSUFFICIENT, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_PAYMENT_INSUFFICIENT, "payment insufficient"); } return false; @@ -1295,8 +1308,8 @@ begin_transaction (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_STORE_TRANSACTION_ERROR, - "Soft merchant database error: retry counter exceeded"); + TALER_EC_GENERIC_DB_SOFT_FAILURE, + NULL); return; } GNUNET_assert (GNUNET_YES == pc->suspended); @@ -1326,8 +1339,8 @@ begin_transaction (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error (could not begin transaction)"); + TALER_EC_GENERIC_DB_START_FAILED, + NULL); return; } @@ -1349,8 +1362,8 @@ begin_transaction (struct PayContext *pc) GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error"); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "deposits"); return; } @@ -1372,8 +1385,8 @@ begin_transaction (struct PayContext *pc) GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_FETCH_TRANSACTION_ERROR, - "Merchant database error checking for refunds"); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "lookup refunds"); return; } refunded = (qs > 0); @@ -1419,8 +1432,8 @@ begin_transaction (struct PayContext *pc) } resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_STORE_PAYMENTS_ERROR, - "Could not set contract to 'paid' in DB"); + TALER_EC_GENERIC_DB_STORE_FAILED, + "mark contract paid"); return; } @@ -1437,8 +1450,8 @@ begin_transaction (struct PayContext *pc) } resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_STORE_PAYMENTS_ERROR, - "Database commit mark proposal as 'paid' failed"); + TALER_EC_GENERIC_DB_COMMIT_FAILED, + NULL); return; } @@ -1489,7 +1502,7 @@ begin_transaction (struct PayContext *pc) GNUNET_break (0); resume_pay_with_error (pc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_JSON_ALLOCATION_FAILURE, + TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, "Could not build final response"); return; } @@ -1562,7 +1575,7 @@ parse_pay (struct MHD_Connection *connection, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PAY_COINS_ARRAY_EMPTY, + TALER_EC_GENERIC_PARAMETER_MISSING, "'coins' array is empty or not even an array"); } @@ -1641,8 +1654,8 @@ parse_pay (struct MHD_Connection *connection, return (MHD_YES == TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_FETCH_PAY_ERROR, - NULL)) + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms")) ? GNUNET_NO : GNUNET_SYSERR; } @@ -1651,7 +1664,7 @@ parse_pay (struct MHD_Connection *connection, return (MHD_YES == TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PAY_PROPOSAL_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, pc->order_id)) ? GNUNET_NO : GNUNET_SYSERR; @@ -1667,7 +1680,7 @@ parse_pay (struct MHD_Connection *connection, return (MHD_YES == TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_FAILED_COMPUTE_PROPOSAL_HASH, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, NULL)) ? GNUNET_NO : GNUNET_SYSERR; @@ -1687,7 +1700,7 @@ parse_pay (struct MHD_Connection *connection, return (MHD_YES == TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_MERCHANT_FIELD_MISSING, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_MERCHANT_FIELD_MISSING, NULL)) ? GNUNET_NO : GNUNET_SYSERR; @@ -1742,7 +1755,7 @@ parse_pay (struct MHD_Connection *connection, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE, NULL); } @@ -1753,7 +1766,7 @@ parse_pay (struct MHD_Connection *connection, return (MHD_YES == TALER_MHD_reply_with_error (connection, MHD_HTTP_GONE, - TALER_EC_PAY_OFFER_EXPIRED, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_OFFER_EXPIRED, NULL)) ? GNUNET_NO : GNUNET_SYSERR; @@ -1773,7 +1786,7 @@ parse_pay (struct MHD_Connection *connection, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_WIRE_HASH_UNKNOWN, + TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_WIRE_HASH_UNKNOWN, NULL); } pc->wm = wm; @@ -1803,9 +1816,9 @@ handle_pay_timeout (void *cls) pc->fo = NULL; } resume_pay_with_error (pc, - MHD_HTTP_REQUEST_TIMEOUT, - TALER_EC_PAY_EXCHANGE_TIMEOUT, - "likely the exchange did not reply quickly enough"); + MHD_HTTP_GATEWAY_TIMEOUT, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, + NULL); } diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c index cc12dc03..8c445680 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -130,8 +130,7 @@ struct PostRefundData { /** - * Hashed version of contract terms. All zeros if - * not provided. + * Hashed version of contract terms. All zeros if not provided. */ struct GNUNET_HashCode h_contract_terms; @@ -215,6 +214,11 @@ struct PostRefundData enum TALER_ErrorCode ec; /** + * HTTP status to use for the reply, 0 if not yet known. + */ + unsigned int http_status; + + /** * Set to true if we are dealing with an unclaimed order * (and thus @e h_contract_terms is not set, and certain * DB queries will not work). @@ -340,7 +344,8 @@ exchange_operations_pending (struct PostRefundData *prd) static void check_resume_prd (struct PostRefundData *prd) { - if (exchange_operations_pending (prd)) + if ( (TALER_EC_NONE == prd->ec) && + exchange_operations_pending (prd) ) return; GNUNET_CONTAINER_DLL_remove (prd_head, prd_tail, @@ -423,25 +428,34 @@ exchange_found_cb (void *cls, bool exchange_trusted) { struct CoinRefund *cr = cls; + struct PostRefundData *prd = cr->prd; (void) payto_uri; + (void) wire_fee; + (void) exchange_trusted; cr->fo = NULL; - if (TALER_EC_NONE == hr->ec) + if (NULL == hr) { - cr->rh = TALER_EXCHANGE_refund (eh, - &cr->refund_amount, - &cr->prd->h_contract_terms, - &cr->coin_pub, - cr->rtransaction_id, - &cr->prd->hc->instance->merchant_priv, - &refund_cb, - cr); + prd->http_status = MHD_HTTP_GATEWAY_TIMEOUT; + prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT; + check_resume_prd (prd); return; } - cr->exchange_status = hr->http_status; - cr->exchange_code = hr->ec; - cr->exchange_reply = json_incref ((json_t*) hr->reply); - check_resume_prd (cr->prd); + if (NULL == eh) + { + prd->http_status = MHD_HTTP_BAD_GATEWAY; + prd->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE; + check_resume_prd (prd); + return; + } + cr->rh = TALER_EXCHANGE_refund (eh, + &cr->refund_amount, + &prd->h_contract_terms, + &cr->coin_pub, + cr->rtransaction_id, + &prd->hc->instance->merchant_priv, + &refund_cb, + cr); } @@ -569,16 +583,16 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms"); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_GET_ORDERS_ORDER_NOT_FOUND, - NULL); + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, + hc->infix); } { struct GNUNET_HashCode h_contract_terms; @@ -590,21 +604,50 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_FAILED_COMPUTE_PROPOSAL_HASH, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, NULL); } json_decref (contract_terms); if (0 != GNUNET_memcmp (&h_contract_terms, &prd->h_contract_terms)) { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_GET_ORDER_WRONG_CONTRACT, - NULL); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_MERCHANT_GENERIC_CONTRACT_HASH_DOES_NOT_MATCH_ORDER, + NULL); } } } } + + if (TALER_EC_NONE != prd->ec) + { + GNUNET_break (0 != prd->http_status); + /* kill pending coin refund operations immediately, just to be + extra sure they don't modify 'prd' after we already created + a reply (this might not be needed, but feels safer). */ + for (struct CoinRefund *cr = prd->cr_head; + NULL != cr; + cr = cr->next) + { + if (NULL != cr->fo) + { + TMH_EXCHANGES_find_exchange_cancel (cr->fo); + cr->fo = NULL; + } + if (NULL != cr->rh) + { + TALER_EXCHANGE_refund_cancel (cr->rh); + cr->rh = NULL; + } + } + return TALER_MHD_reply_with_error (connection, + prd->http_status, + prd->ec, + NULL); + } + { GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TMH_currency, &prd->refund_amount)); @@ -618,8 +661,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "detailed refunds"); } } @@ -641,8 +684,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_SOFT_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "refund proof"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: if (NULL == cr->exchange_reply) { diff --git a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c index 79c58632..29b8f13e 100644 --- a/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c +++ b/src/backend/taler-merchant-httpd_post-tips-ID-pickup.c @@ -292,7 +292,7 @@ withdraw_cb (void *cls, pc->response = TALER_MHD_make_json_pack ( "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_TIP_PICKUP_EXCHANGE_ERROR, + "code", (json_int_t) TALER_EC_MERCHANT_TIP_PICKUP_EXCHANGE_ERROR, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", (json_int_t) hr->http_status, "exchange_reply", hr->reply); @@ -309,8 +309,8 @@ withdraw_cb (void *cls, stop_operations (pc); pc->http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; pc->response = TALER_MHD_make_error ( - TALER_EC_TIP_PICKUP_DB_STORE_HARD_ERROR, - "Could not store blind signature in DB"); + TALER_EC_GENERIC_DB_STORE_FAILED, + "blind signature"); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -348,17 +348,37 @@ do_withdraw (void *cls, struct PickupContext *pc = po->pc; po->fo = NULL; + if (NULL == hr) + { + stop_operations (pc); + GNUNET_CONTAINER_DLL_remove (pc->po_head, + pc->po_tail, + po); + pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; + pc->response = TALER_MHD_make_json_pack ( + "{s:s, s:I}", + "hint", + TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT), + "code", + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT); + MHD_resume_connection (pc->connection); + TMH_trigger_daemon (); /* we resumed, kick MHD */ + return; + } if (NULL == eh) { stop_operations (pc); GNUNET_CONTAINER_DLL_remove (pc->po_head, pc->po_tail, po); - pc->http_status = MHD_HTTP_FAILED_DEPENDENCY; + pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = TALER_MHD_make_json_pack ( - "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_TIP_PICKUP_CONTACT_EXCHANGE_ERROR, + "{s:s, s:I, s:I, s:I, s:O?}", + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", (json_int_t) hr->http_status, "exchange_reply", hr->reply); @@ -422,10 +442,10 @@ do_timeout (void *cls) pc->tt = NULL; stop_operations (pc); - pc->http_status = MHD_HTTP_REQUEST_TIMEOUT; + pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; pc->response = TALER_MHD_make_error ( - TALER_EC_TIP_PICKUP_EXCHANGE_TIMEOUT, - "Timeout trying to withdraw from exchange (try again later)"); + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, + NULL); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ } @@ -457,14 +477,43 @@ compute_total_requested (void *cls, pc->fo = NULL; stop_operations (pc); /* stops timeout job */ - if ( (NULL == eh) || - (NULL == (keys = TALER_EXCHANGE_get_keys (eh))) ) + if (NULL == hr) { - pc->http_status = MHD_HTTP_FAILED_DEPENDENCY; + pc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; + pc->response = TALER_MHD_make_json_pack ( + "{s:I, s:s}", + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); + MHD_resume_connection (pc->connection); + TMH_trigger_daemon (); /* we resumed, kick MHD */ + return; + } + if (NULL == eh) + { + pc->http_status = MHD_HTTP_BAD_GATEWAY; pc->response = TALER_MHD_make_json_pack ( - "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_TIP_PICKUP_EXCHANGE_KEYS_ERROR, + "{s:I, s:s, s:I, s:I, s:O}", + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), + "exchange_code", (json_int_t) hr->ec, + "exchange_http_status", (json_int_t) hr->http_status, + "exchange_reply", hr->reply); + MHD_resume_connection (pc->connection); + TMH_trigger_daemon (); /* we resumed, kick MHD */ + return; + } + if (NULL == (keys = TALER_EXCHANGE_get_keys (eh))) + { + pc->http_status = MHD_HTTP_BAD_GATEWAY; + pc->response = + TALER_MHD_make_json_pack ( + "{s:I, s:s, s:I, s:I, s:O}", + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE, + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE), "exchange_code", (json_int_t) hr->ec, "exchange_http_status", (json_int_t) hr->http_status, "exchange_reply", hr->reply); @@ -488,7 +537,8 @@ compute_total_requested (void *cls, pc->response = TALER_MHD_make_json_pack ( "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_TIP_PICKUP_DENOMINATION_UNKNOWN, + "code", + (json_int_t) TALER_EC_MERCHANT_TIP_PICKUP_DENOMINATION_UNKNOWN, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", (json_int_t) hr->http_status, "exchange_reply", hr->reply); @@ -507,7 +557,7 @@ compute_total_requested (void *cls, { pc->http_status = MHD_HTTP_BAD_REQUEST; pc->response = - TALER_MHD_make_error (TALER_EC_TIP_PICKUP_SUMMATION_FAILED, + TALER_MHD_make_error (TALER_EC_MERCHANT_TIP_PICKUP_SUMMATION_FAILED, "Could not add up values to compute pickup total"); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ @@ -538,20 +588,20 @@ reply_lookup_tip_failed (struct MHD_Connection *connection, switch (qs) { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - ec = TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN; + ec = TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN; response_code = MHD_HTTP_NOT_FOUND; break; case GNUNET_DB_STATUS_SOFT_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_SOFT; + ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; case GNUNET_DB_STATUS_HARD_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_HARD; + ec = TALER_EC_GENERIC_DB_COMMIT_FAILED; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; default: GNUNET_break (0); - ec = TALER_EC_INTERNAL_LOGIC_ERROR; + ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; } @@ -604,7 +654,7 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, hc->infix); } @@ -632,7 +682,7 @@ TMH_post_tips_ID_pickup (const struct TMH_RequestHandler *rh, json_decref (planchets); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "planchets"); } @@ -735,7 +785,7 @@ RETRY: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_TIP_PICKUP_DB_ERROR_SOFT, + TALER_EC_GENERIC_DB_SOFT_FAILURE, NULL); } if (GNUNET_OK != @@ -745,7 +795,7 @@ RETRY: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_TIP_PICKUP_DB_ERROR_HARD, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } { @@ -827,12 +877,12 @@ RETRY: goto RETRY; break; case GNUNET_DB_STATUS_HARD_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_HARD; + ec = TALER_EC_GENERIC_DB_FETCH_FAILED; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; default: GNUNET_break (0); - ec = TALER_EC_INTERNAL_LOGIC_ERROR; + ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; } @@ -861,7 +911,7 @@ RETRY: TMH_db->rollback (TMH_db->cls); return TALER_MHD_reply_with_error (connection, MHD_HTTP_GONE, - TALER_EC_TIP_PICKUP_HAS_EXPIRED, + TALER_EC_MERCHANT_TIP_PICKUP_HAS_EXPIRED, hc->infix); } if (0 > @@ -873,8 +923,8 @@ RETRY: TMH_db->rollback (TMH_db->cls); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, - hc->infix); + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "picked up amount exceeds authorized amount"); } if (0 > @@ -885,7 +935,7 @@ RETRY: TMH_db->rollback (TMH_db->cls); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_TIP_PICKUP_AMOUNT_EXCEEDS_TIP_REMAINING, + TALER_EC_MERCHANT_TIP_PICKUP_AMOUNT_EXCEEDS_TIP_REMAINING, hc->infix); } @@ -906,8 +956,8 @@ RETRY: goto RETRY; return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_TIP_PICKUP_DB_STORE_HARD_ERROR, - NULL); + TALER_EC_GENERIC_DB_STORE_FAILED, + "pickup"); } qs = TMH_db->commit (TMH_db->cls); if (qs < 0) @@ -917,7 +967,7 @@ RETRY: goto RETRY; return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_TIP_PICKUP_DB_STORE_HARD_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); } MHD_suspend_connection (connection); diff --git a/src/backend/taler-merchant-httpd_private-delete-instances-ID.c b/src/backend/taler-merchant-httpd_private-delete-instances-ID.c index c7432f04..1b1184cf 100644 --- a/src/backend/taler-merchant-httpd_private-delete-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-delete-instances-ID.c @@ -57,18 +57,18 @@ TMH_private_delete_instances_ID (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_DELETE_INSTANCES_ID_DB_HARD_FAILURE, - NULL); + TALER_EC_GENERIC_DB_STORE_FAILED, + "delete private key"); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, NULL); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_DELETE_INSTANCES_ID_NO_SUCH_INSTANCE, + TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN, ( (NULL != purge) && (0 == strcmp (purge, "yes")) ) diff --git a/src/backend/taler-merchant-httpd_private-delete-orders-ID.c b/src/backend/taler-merchant-httpd_private-delete-orders-ID.c index aadcb77e..057b45c3 100644 --- a/src/backend/taler-merchant-httpd_private-delete-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-delete-orders-ID.c @@ -53,13 +53,13 @@ TMH_private_delete_orders_ID (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_DELETE_DB_HARD_FAILURE, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, NULL); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: { @@ -85,11 +85,11 @@ TMH_private_delete_orders_ID (const struct TMH_RequestHandler *rh, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_ORDERS_DELETE_NO_SUCH_ORDER, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, hc->infix); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_ORDERS_DELETE_AWAITING_PAYMENT, + TALER_EC_MERCHANT_PRIVATE_DELETE_ORDERS_AWAITING_PAYMENT, hc->infix); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return TALER_MHD_reply_static (connection, diff --git a/src/backend/taler-merchant-httpd_private-delete-products-ID.c b/src/backend/taler-merchant-httpd_private-delete-products-ID.c index 054cf3a8..2d17bafc 100644 --- a/src/backend/taler-merchant-httpd_private-delete-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-delete-products-ID.c @@ -48,13 +48,13 @@ TMH_private_delete_products_ID (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PRODUCTS_DELETE_DB_HARD_FAILURE, + TALER_EC_GENERIC_DB_STORE_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, NULL); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: qs = TMH_db->lookup_product (TMH_db->cls, @@ -64,12 +64,13 @@ TMH_private_delete_products_ID (const struct TMH_RequestHandler *rh, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PRODUCTS_DELETE_NO_SUCH_PRODUCT, + TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN, hc->infix); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_PRODUCTS_DELETE_CONFLICTING_LOCK, - hc->infix); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_PRIVATE_DELETE_PRODUCTS_CONFLICTING_LOCK, + hc->infix); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, diff --git a/src/backend/taler-merchant-httpd_private-delete-reserves-ID.c b/src/backend/taler-merchant-httpd_private-delete-reserves-ID.c index 86d53327..96483384 100644 --- a/src/backend/taler-merchant-httpd_private-delete-reserves-ID.c +++ b/src/backend/taler-merchant-httpd_private-delete-reserves-ID.c @@ -50,7 +50,7 @@ TMH_private_delete_reserves_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_RESERVES_INVALID_RESERVE_PUB, + TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED, hc->infix); } purge = MHD_lookup_connection_value (connection, @@ -72,18 +72,18 @@ TMH_private_delete_reserves_ID (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_RESERVES_DELETE_DB_HARD_FAILURE, + TALER_EC_GENERIC_DB_STORE_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_DB_SOFT_FAILURE, "Serialization error for single SQL statement"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_RESERVES_DELETE_NO_SUCH_RESERVE, + TALER_EC_MERCHANT_PRIVATE_DELETE_RESERVES_NO_SUCH_RESERVE, hc->infix); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return TALER_MHD_reply_static (connection, diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 9f0b9fef..6d4d625c 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -376,7 +376,7 @@ exchange_timeout_cb (void *cls) gorc->tt = NULL; gorc_resume (gorc, MHD_HTTP_REQUEST_TIMEOUT, - TALER_EC_GET_ORDERS_EXCHANGE_TIMEOUT); + TALER_EC_GENERIC_TIMEOUT); } @@ -401,7 +401,7 @@ deposit_get_cb (void *cls, if (NULL == dd) { gorc_report (gorc, - TALER_EC_GET_ORDERS_EXCHANGE_TRACKING_FAILURE, + TALER_EC_MERCHANT_GET_ORDERS_EXCHANGE_TRACKING_FAILURE, &tq->coin_pub, hr); GNUNET_free (tq); @@ -421,7 +421,7 @@ deposit_get_cb (void *cls, if (qs < 0) { gorc_report (gorc, - TALER_EC_GET_ORDERS_DB_STORE_TRACKING_FAILURE, + TALER_EC_GENERIC_DB_STORE_FAILED, &tq->coin_pub, NULL); GNUNET_free (tq); @@ -438,7 +438,7 @@ deposit_get_cb (void *cls, &dd->coin_contribution)) { gorc_report (gorc, - TALER_EC_GET_ORDERS_AMOUNT_ARITHMETIC_FAILURE, + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, &tq->coin_pub, NULL); GNUNET_free (tq); @@ -454,7 +454,7 @@ deposit_get_cb (void *cls, &tq->deposit_fee)) { gorc_report (gorc, - TALER_EC_GET_ORDERS_AMOUNT_ARITHMETIC_FAILURE, + TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_ID_AMOUNT_ARITHMETIC_FAILURE, &tq->coin_pub, NULL); GNUNET_free (tq); @@ -506,6 +506,18 @@ exchange_found_cb (void *cls, struct GetOrderRequestContext *gorc = tq->gorc; tq->fo = NULL; + if (NULL == hr) + { + /* failed */ + GNUNET_CONTAINER_DLL_remove (gorc->tq_head, + gorc->tq_tail, + tq); + GNUNET_free (tq); + gorc_resume (gorc, + MHD_HTTP_GATEWAY_TIMEOUT, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT); + return; + } if (NULL == eh) { /* failed */ @@ -516,8 +528,8 @@ exchange_found_cb (void *cls, gorc->exchange_hc = hr->http_status; gorc->exchange_ec = hr->ec; gorc_resume (gorc, - MHD_HTTP_FAILED_DEPENDENCY, - TALER_EC_GET_ORDERS_EXCHANGE_LOOKUP_FAILURE); + MHD_HTTP_BAD_GATEWAY, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE); return; } tq->dgh = TALER_EXCHANGE_deposits_get (eh, @@ -535,7 +547,7 @@ exchange_found_cb (void *cls, GNUNET_free (tq); gorc_resume (gorc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_EXCHANGE_REQUEST_FAILURE); + TALER_EC_MERCHANT_GET_ORDERS_ID_EXCHANGE_REQUEST_FAILURE); } } @@ -587,7 +599,7 @@ deposit_cb (void *cls, { gorc_resume (gorc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_EXCHANGE_LOOKUP_START_FAILURE); + TALER_EC_MERCHANT_GET_ORDERS_ID_EXCHANGE_LOOKUP_START_FAILURE); } } @@ -783,7 +795,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "timeout_ms must be non-negative number"); } gorc->sc.long_poll_timeout @@ -847,8 +859,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms"); } { @@ -873,14 +885,14 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order"); } if (order_only && (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ) { return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_GET_ORDERS_ORDER_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, hc->infix); } if (order_only) @@ -909,7 +921,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, hc->infix); } if (0 != @@ -920,7 +932,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_CONTRACT_TERMS_ERROR, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, gorc->contract_amount.currency); } } @@ -936,7 +948,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_FAILED_COMPUTE_PROPOSAL_HASH, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, NULL); } } @@ -973,8 +985,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_PAYMENT_STATUS, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "payment status"); } } if ( (! paid) && @@ -999,8 +1011,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_PAYMENT_STATUS, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "order by fulfillment"); } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { @@ -1155,8 +1167,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_DB_FETCH_TRANSACTION_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "detailed refunds"); } /* Generate final reply, including wire details if we have them */ @@ -1179,8 +1191,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PAY_DB_FETCH_TRANSACTION_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "transfer details"); } if (! wired) @@ -1195,10 +1207,11 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->refund_amount)) { GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_CONTRACT_CONTENT_INVALID, - "refund exceeds contract value"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, + "refund exceeds contract value"); } if (0 > TALER_amount_subtract (&expect_total, @@ -1206,10 +1219,11 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, &gorc->deposit_fees_total)) { GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_ORDERS_CONTRACT_CONTENT_INVALID, - "deposit fees exceed total minus refunds"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, + "deposit fees exceed total minus refunds"); } if (0 >= TALER_amount_cmp (&expect_total, diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 8df4e69c..83ca09f9 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -272,7 +272,7 @@ add_order (void *cls, if (qs < 0) { GNUNET_break (0); - aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_STATUS_DB_LOOKUP_ERROR; + aos->result = TALER_EC_GENERIC_DB_FETCH_FAILED; return; } } @@ -304,7 +304,7 @@ add_order (void *cls, if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (0); - aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_CONTRACT_DB_LOOKUP_ERROR; + aos->result = TALER_EC_GENERIC_DB_FETCH_FAILED; json_decref (contract_terms); return; } @@ -329,7 +329,7 @@ add_order (void *cls, NULL, NULL)) { GNUNET_break (0); - aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_PARSE_CONTRACT_ERROR; + aos->result = TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID; json_decref (contract_terms); return; } @@ -350,8 +350,7 @@ add_order (void *cls, if (0 > qs) { GNUNET_break (0); - aos->result = - TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_REFUND_DB_LOOKUP_ERROR; + aos->result = TALER_EC_GENERIC_DB_FETCH_FAILED; json_decref (contract_terms); return; } @@ -497,7 +496,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &of.paid)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "paid"); if (! (TALER_arg_to_yna (connection, "refunded", @@ -505,7 +504,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &of.refunded)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "refunded"); if (! (TALER_arg_to_yna (connection, "wired", @@ -513,7 +512,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &of.wired)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "wired"); { const char *start_row_str; @@ -537,7 +536,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "date"); of.start_row = (uint64_t) ull; } @@ -564,7 +563,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "delta"); of.delta = (uint64_t) ll; } @@ -589,7 +588,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, &of.date)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "date"); } } @@ -615,7 +614,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "timeout_ms"); of.timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, ull); @@ -636,8 +635,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, aos); if (0 > qs) { - aos->result = - TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_BY_FILTER_DB_LOOKUP_ERROR; + aos->result = TALER_EC_GENERIC_DB_FETCH_FAILED; } if (TALER_EC_NONE != aos->result) { diff --git a/src/backend/taler-merchant-httpd_private-get-products-ID.c b/src/backend/taler-merchant-httpd_private-get-products-ID.c index db5c223e..915b016c 100644 --- a/src/backend/taler-merchant-httpd_private-get-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-products-ID.c @@ -50,14 +50,14 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_PRODUCTS_DB_LOOKUP_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, NULL); } else if (0 == qs) { return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_GET_PRODUCTS_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN, NULL); } { diff --git a/src/backend/taler-merchant-httpd_private-get-products.c b/src/backend/taler-merchant-httpd_private-get-products.c index fc07d311..9d8b40f8 100644 --- a/src/backend/taler-merchant-httpd_private-get-products.c +++ b/src/backend/taler-merchant-httpd_private-get-products.c @@ -72,7 +72,7 @@ TMH_private_get_products (const struct TMH_RequestHandler *rh, json_decref (pa); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_PRODUCTS_DB_LOOKUP_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, NULL); } return TALER_MHD_reply_json_pack (connection, diff --git a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c index 9d7839f9..35d3707d 100644 --- a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c @@ -152,7 +152,7 @@ TMH_private_get_reserves_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, hc->infix); } { @@ -187,20 +187,20 @@ TMH_private_get_reserves_ID (const struct TMH_RequestHandler *rh, switch (qs) { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - ec = TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN; + ec = TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN; response_code = MHD_HTTP_NOT_FOUND; break; case GNUNET_DB_STATUS_SOFT_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_SOFT; + ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; case GNUNET_DB_STATUS_HARD_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_HARD; + ec = TALER_EC_GENERIC_DB_FETCH_FAILED; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; default: GNUNET_break (0); - ec = TALER_EC_INTERNAL_LOGIC_ERROR; + ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; } diff --git a/src/backend/taler-merchant-httpd_private-get-reserves.c b/src/backend/taler-merchant-httpd_private-get-reserves.c index a495da4e..8b12afbe 100644 --- a/src/backend/taler-merchant-httpd_private-get-reserves.c +++ b/src/backend/taler-merchant-httpd_private-get-reserves.c @@ -107,7 +107,7 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "active"); } @@ -118,7 +118,7 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "failures"); } @@ -137,8 +137,8 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, json_decref (ra); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_RESERVES_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "reserves"); } return TALER_MHD_reply_json_pack (connection, MHD_HTTP_OK, diff --git a/src/backend/taler-merchant-httpd_private-get-tips-ID.c b/src/backend/taler-merchant-httpd_private-get-tips-ID.c index f1a3254c..7ebe6b9c 100644 --- a/src/backend/taler-merchant-httpd_private-get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-tips-ID.c @@ -54,7 +54,7 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, hc->infix); } { @@ -87,20 +87,20 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, switch (qs) { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - ec = TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN; + ec = TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN; response_code = MHD_HTTP_NOT_FOUND; break; case GNUNET_DB_STATUS_SOFT_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_SOFT; + ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; case GNUNET_DB_STATUS_HARD_ERROR: - ec = TALER_EC_TIP_PICKUP_DB_ERROR_HARD; + ec = TALER_EC_GENERIC_DB_COMMIT_FAILED; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; default: GNUNET_break (0); - ec = TALER_EC_INTERNAL_LOGIC_ERROR; + ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; break; } diff --git a/src/backend/taler-merchant-httpd_private-get-tips.c b/src/backend/taler-merchant-httpd_private-get-tips.c index 4282ebe7..60e4900e 100644 --- a/src/backend/taler-merchant-httpd_private-get-tips.c +++ b/src/backend/taler-merchant-httpd_private-get-tips.c @@ -69,7 +69,7 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, &expired)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "expired"); { const char *limit_str; @@ -93,7 +93,7 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "limit"); limit = (uint64_t) ll; } @@ -123,7 +123,7 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "offset"); offset = (uint64_t) ull; } @@ -145,8 +145,8 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, json_decref (pa); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_GET_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "tips"); } return TALER_MHD_reply_json_pack (connection, diff --git a/src/backend/taler-merchant-httpd_private-get-transfers.c b/src/backend/taler-merchant-httpd_private-get-transfers.c index ffff32be..3ac15d01 100644 --- a/src/backend/taler-merchant-httpd_private-get-transfers.c +++ b/src/backend/taler-merchant-httpd_private-get-transfers.c @@ -121,7 +121,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, &before)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "before"); } { @@ -136,7 +136,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, &after)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "after"); } { @@ -157,7 +157,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "limit"); limit = (int64_t) l; } @@ -180,7 +180,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, dummy)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "offset"); offset = (uint64_t) o; } @@ -198,7 +198,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, &verified)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "verified"); TMH_db->preflight (TMH_db->cls); @@ -226,8 +226,8 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GET_TRANSFERS_DB_FETCH_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "transfers"); } return TALER_MHD_reply_json_pack (connection, MHD_HTTP_OK, diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index 1534f62b..755e6f02 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -104,7 +104,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, if (! json_is_array (payto_uris)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PATCH_INSTANCES_BAD_PAYTO_URIS, + TALER_EC_GENERIC_PAYTO_URI_MALFORMED, NULL); for (unsigned int i = 0; i<MAX_RETRIES; i++) { @@ -129,7 +129,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_PATCH_INSTANCES_BAD_CURRENCY, + TALER_EC_GENERIC_CURRENCY_MISMATCH, NULL); } if (GNUNET_OK != @@ -139,7 +139,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PATCH_INSTANCES_DB_START_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } /* Check for equality of settings */ @@ -207,7 +207,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, GNUNET_assert (NULL == wm_head); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_POST_INSTANCES_BAD_PAYTO_URIS, + TALER_EC_GENERIC_PAYTO_URI_MALFORMED, NULL); } if ((0 == strcasecmp (uri, @@ -221,7 +221,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, GNUNET_assert (NULL == wm_head); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_POST_INSTANCES_BAD_PAYTO_URIS, + TALER_EC_GENERIC_PAYTO_URI_MALFORMED, str); } matches[i] = true; @@ -292,7 +292,7 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_POST_INSTANCES_BAD_PAYTO_URIS, + TALER_EC_GENERIC_PAYTO_URI_MALFORMED, ad.payto_uri); } wm->active = true; @@ -336,7 +336,7 @@ giveup: GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PATCH_INSTANCES_DB_COMMIT_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); } /* Deactivate existing wire methods that were removed above */ diff --git a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c index d9d8df49..494787ed 100644 --- a/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c +++ b/src/backend/taler-merchant-httpd_private-patch-orders-ID-forget.c @@ -81,7 +81,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_FORGET_ORDER_DB_START_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } qs = TMH_db->lookup_contract_terms (TMH_db->cls, @@ -95,8 +95,8 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, TMH_db->rollback (TMH_db->cls); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ORDERS_CLAIM_HARD_DB_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "contract terms"); case GNUNET_DB_STATUS_SOFT_ERROR: TMH_db->rollback (TMH_db->cls); continue; @@ -104,7 +104,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, TMH_db->rollback (TMH_db->cls); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_FORGET_ORDER_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, order_id); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: GNUNET_assert (NULL != contract_terms); @@ -138,7 +138,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, json_decref (fields); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "fields"); } @@ -156,7 +156,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, json_decref (fields); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_FORGET_PATH_SYNTAX_INCORRECT, + TALER_EC_MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_SYNTAX_INCORRECT, "field is not a string"); } expand_status = TALER_JSON_expand_path (contract_terms, @@ -171,7 +171,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, json_decref (fields); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_FORGET_PATH_NOT_FORGETTABLE, + TALER_EC_MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_NOT_FORGETTABLE, json_string_value (value)); } if (GNUNET_SYSERR == expand_status) @@ -182,7 +182,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, json_decref (fields); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_FORGET_PATH_SYNTAX_INCORRECT, + TALER_EC_MERCHANT_PRIVATE_PATCH_ORDERS_ID_FORGET_PATH_SYNTAX_INCORRECT, json_string_value (value)); } } @@ -211,7 +211,7 @@ TMH_private_patch_orders_ID_forget (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_FORGET_ORDER_DB_COMMIT_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); } diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c b/src/backend/taler-merchant-httpd_private-patch-products-ID.c index 5fd3a1ef..dd989866 100644 --- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c @@ -59,18 +59,18 @@ determine_cause (struct MHD_Connection *connection, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PRODUCTS_PATCH_DB_COMMIT_HARD_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, "unexpected serialization problem"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PRODUCTS_PATCH_UNKNOWN_PRODUCT, + TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN, product_id); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: break; /* do below */ @@ -79,13 +79,13 @@ determine_cause (struct MHD_Connection *connection, { enum TALER_ErrorCode ec; - ec = TALER_EC_INTERNAL_INVARIANT_FAILURE; + ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; if (pdx.total_lost > pd->total_lost) - ec = TALER_EC_PRODUCTS_PATCH_TOTAL_LOST_REDUCED; + ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_REDUCED; if (pdx.total_stock > pd->total_stock) - ec = TALER_EC_PRODUCTS_PATCH_TOTAL_STOCKED_REDUCED; + ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_STOCKED_REDUCED; if (pd->total_stock - pdx.total_sold > pd->total_lost) - ec = TALER_EC_PRODUCTS_PATCH_TOTAL_LOST_EXCEEDS_STOCKS; + ec = TALER_EC_MERCHANT_PRIVATE_PATCH_PRODUCTS_TOTAL_LOST_EXCEEDS_STOCKS; GNUNET_free (pdx.description); json_decref (pdx.description_i18n); GNUNET_free (pdx.unit); @@ -195,14 +195,14 @@ TMH_private_patch_products_ID (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PRODUCTS_PATCH_DB_COMMIT_HARD_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, NULL); break; case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, "unexpected serialization problem"); break; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 1a9d2b27..1cd1a0bb 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -189,8 +189,8 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_POST_INSTANCES_BAD_CURRENCY, - NULL); + TALER_EC_GENERIC_CURRENCY_MISMATCH, + TMH_currency); } { @@ -240,7 +240,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_POST_INSTANCES_ALREADY_EXISTS, + TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS, is.id); } } @@ -338,7 +338,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_POST_INSTANCES_BAD_PAYTO_URIS, + TALER_EC_GENERIC_PAYTO_URI_MALFORMED, NULL); } } @@ -369,7 +369,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, free_mi (mi); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_INSTANCES_DB_START_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } qs = TMH_db->insert_instance (TMH_db->cls, @@ -424,7 +424,7 @@ retry: free_mi (mi); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_INSTANCES_DB_COMMIT_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); } /* Finally, also update our running process */ diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c index 59b82752..49bc1b6e 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c @@ -145,10 +145,11 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, GNUNET_break (0); GNUNET_JSON_parse_free (spec); json_decref (contract_terms); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, - "Failed to parse contract terms from DB"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_MERCHANT_GENERIC_DB_CONTRACT_CONTENT_INVALID, + "mandatory fields missing"); } json_decref (contract_terms); if (timestamp.abs_value_us == refund_deadline.abs_value_us) @@ -175,7 +176,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_REFUND_ORDER_ID_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, hc->infix); } } @@ -202,7 +203,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_REFUND_STORE_DB_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } rs = TMH_db->increase_refund (TMH_db->cls, @@ -242,13 +243,13 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, TALER_amount2s (&refund)); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_REFUND_INCONSISTENT_AMOUNT, + TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT, "Amount above payment"); case TALER_MERCHANTDB_RS_SOFT_ERROR: case TALER_MERCHANTDB_RS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_REFUND_MERCHANT_DB_COMMIT_ERROR, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); case TALER_MERCHANTDB_RS_NO_SUCH_ORDER: { @@ -256,10 +257,11 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, "lookup_contract_terms" at the beginning; so if we get 'no such order' here, it must be read as "no PAID order" */ - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_REFUND_ORDER_ID_UNPAID, - hc->infix); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ID_REFUND_ORDER_UNPAID, + hc->infix); } case TALER_MERCHANTDB_RS_SUCCESS: { @@ -276,7 +278,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_REFUND_ORDER_ID_UNKNOWN, + TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN, hc->infix); } if (GNUNET_OK != @@ -287,7 +289,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, json_decref (contract_terms); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_LOGIC_ERROR, + TALER_EC_GENERIC_FAILED_COMPUTE_JSON_HASH, "Could not hash contract terms"); } json_decref (contract_terms); @@ -319,7 +321,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_REFUND_DB_INCONSISTENT, + TALER_EC_GENERIC_DB_INVARIANT_FAILURE, NULL); } TMH_notify_order_change (hc->instance, diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index bac98d43..b0bfa30f 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -400,7 +400,7 @@ execute_order (struct MHD_Connection *connection, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_CONFLICT, - TALER_EC_PROPOSAL_ORDER_BAD_CURRENCY, + TALER_EC_GENERIC_CURRENCY_MISMATCH, TMH_currency); } @@ -415,7 +415,7 @@ execute_order (struct MHD_Connection *connection, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "order:wire_transfer_deadline;order:refund_deadline"); } @@ -426,7 +426,7 @@ execute_order (struct MHD_Connection *connection, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "order:products"); } @@ -477,10 +477,11 @@ execute_order (struct MHD_Connection *connection, /* This request is not idempotent */ MHD_RESULT ret; - ret = TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS, - order_id); + ret = TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ALREADY_EXISTS, + order_id); GNUNET_JSON_parse_free (spec); return ret; } @@ -515,7 +516,7 @@ execute_order (struct MHD_Connection *connection, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PROPOSAL_STORE_DB_ERROR_SOFT, + TALER_EC_GENERIC_DB_SOFT_FAILURE, NULL); } @@ -523,10 +524,11 @@ execute_order (struct MHD_Connection *connection, { /* should be: contract (!) with same order ID already exists */ - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS, - order_id); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_ALREADY_EXISTS, + order_id); } /* If we have a product that has insufficient quantities, @@ -563,7 +565,7 @@ execute_order (struct MHD_Connection *connection, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PROPOSAL_STORE_DB_ERROR_HARD, + TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); } /* DB transaction succeeded, generate positive response */ @@ -696,7 +698,7 @@ patch_order (struct MHD_Connection *connection, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PROPOSAL_NO_LOCALTIME, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_NO_LOCALTIME, NULL); } off = strftime (buf, @@ -755,7 +757,7 @@ patch_order (struct MHD_Connection *connection, { struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); - + (void) GNUNET_TIME_round_abs (&now); /* Add timestamp if it doesn't exist (or is zero) */ if (0 == timestamp.abs_value_us) @@ -767,7 +769,8 @@ patch_order (struct MHD_Connection *connection, } /* If no refund_deadline given, set one based on refund_delay. */ - if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == refund_deadline.abs_value_us) + if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == + refund_deadline.abs_value_us) { struct GNUNET_TIME_Absolute rd = GNUNET_TIME_relative_to_absolute (refund_delay); @@ -858,7 +861,7 @@ patch_order (struct MHD_Connection *connection, return TALER_MHD_reply_with_error ( connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PROPOSAL_ORDER_PARSE_ERROR, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_PROPOSAL_PARSE_ERROR, "'merchant' field already set, but must be provided by backend"); } else @@ -986,7 +989,7 @@ add_payment_details (struct MHD_Connection *connection, hc->instance->settings.id); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PROPOSAL_INSTANCE_CONFIGURATION_LACKS_WIRE, + TALER_EC_MERCHANT_PRIVATE_POST_ORDERS_INSTANCE_CONFIGURATION_LACKS_WIRE, payment_target); } GNUNET_assert (0 == @@ -1067,23 +1070,23 @@ merge_inventory (struct MHD_Connection *connection, &pd); if (qs <= 0) { - enum TALER_ErrorCode ec = TALER_EC_INTERNAL_INVARIANT_FAILURE; + enum TALER_ErrorCode ec = TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE; unsigned int http_status = 0; switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - ec = TALER_EC_ORDERS_LOOKUP_PRODUCT_DB_HARD_FAILURE; + ec = TALER_EC_GENERIC_DB_FETCH_FAILED; break; case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); http_status = MHD_HTTP_INTERNAL_SERVER_ERROR; - ec = TALER_EC_ORDERS_LOOKUP_PRODUCT_DB_SOFT_FAILURE; + ec = TALER_EC_GENERIC_DB_SOFT_FAILURE; break; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: http_status = MHD_HTTP_NOT_FOUND; - ec = TALER_EC_ORDERS_LOOKUP_PRODUCT_NOT_FOUND; + ec = TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN; break; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: /* case listed to make compilers happy */ @@ -1253,7 +1256,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_ALLOCATION_FAILURE, + TALER_EC_GENERIC_ALLOCATION_FAILURE, "request body normalization for hashing"); } /* We include the full request: JSON body and the create_token and @@ -1278,7 +1281,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "inventory_products"); } GNUNET_array_grow (ips, @@ -1315,7 +1318,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "inventory_products"); } } @@ -1332,7 +1335,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "lock_uuids"); } GNUNET_array_grow (uuids, @@ -1370,7 +1373,7 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_PARAMETER_MALFORMED, + TALER_EC_GENERIC_PARAMETER_MALFORMED, "lock_uuids"); } } diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c index 6cb6650a..5a27b56f 100644 --- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c +++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c @@ -81,13 +81,13 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, case GNUNET_DB_STATUS_HARD_ERROR: return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PRODUCTS_PATCH_DB_COMMIT_HARD_ERROR, + TALER_EC_GENERIC_DB_STORE_FAILED, NULL); case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_INTERNAL_INVARIANT_FAILURE, + TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, "Serialization error for single-statment request"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: qs = TMH_db->lookup_product (TMH_db->cls, @@ -97,12 +97,12 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_PRODUCTS_LOCK_UNKNOWN_PRODUCT, + TALER_EC_MERCHANT_GENERIC_PRODUCT_UNKNOWN, product_id); else return TALER_MHD_reply_with_error (connection, MHD_HTTP_GONE, - TALER_EC_PRODUCTS_LOCK_INSUFFICIENT_STOCKS, + TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_LOCK_INSUFFICIENT_STOCKS, product_id); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: return TALER_MHD_reply_static (connection, diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c index e77690bc..5b783519 100644 --- a/src/backend/taler-merchant-httpd_private-post-products.c +++ b/src/backend/taler-merchant-httpd_private-post-products.c @@ -136,7 +136,7 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_PRODUCTS_POST_DB_START_ERROR, + TALER_EC_GENERIC_DB_START_FAILED, NULL); } qs = TMH_db->lookup_product (TMH_db->cls, @@ -173,7 +173,7 @@ TMH_private_post_products (const struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_PRODUCTS_POST_CONFLICT_PRODUCT_EXISTS, + TALER_EC_MERCHANT_PRIVATE_POST_PRODUCTS_CONFLICT_PRODUCT_EXISTS, product_id); } } @@ -200,8 +200,8 @@ retry: connection, MHD_HTTP_INTERNAL_SERVER_ERROR, (GNUNET_DB_STATUS_SOFT_ERROR == qs) - ? TALER_EC_PRODUCTS_POST_DB_COMMIT_SOFT_ERROR - : TALER_EC_PRODUCTS_POST_DB_COMMIT_HARD_ERROR, + ? TALER_EC_GENERIC_DB_SOFT_FAILURE + : TALER_EC_GENERIC_DB_COMMIT_FAILED, NULL); return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, diff --git a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c index fa17a0ec..04b40e32 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves-ID-authorize-tip.c @@ -85,16 +85,16 @@ authorize_tip (const struct TMH_RequestHandler *rh, switch (ec) { - case TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS: + case TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS: http_status = MHD_HTTP_PRECONDITION_FAILED; break; - case TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED: + case TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED: http_status = MHD_HTTP_GONE; break; - case TALER_EC_TIP_AUTHORIZE_RESERVE_UNKNOWN: + case TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_UNKNOWN: http_status = MHD_HTTP_SERVICE_UNAVAILABLE; break; - case TALER_EC_TIP_AUTHORIZE_DB_RESERVE_NOT_FOUND: + case TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND: http_status = MHD_HTTP_NOT_FOUND; break; default: @@ -166,7 +166,7 @@ TMH_private_post_reserves_ID_authorize_tip (const struct TMH_RequestHandler *rh, GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, - TALER_EC_RESERVES_INVALID_RESERVE_PUB, + TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED, hc->infix); } return authorize_tip (rh, diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index ce50b24e..e2243936 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -192,22 +192,29 @@ handle_exchange (void *cls, rc); if (NULL == hr) { - rc->ec = TALER_EC_TIMEOUT; - rc->http_status = MHD_HTTP_REQUEST_TIMEOUT; + rc->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT; + rc->http_status = MHD_HTTP_GATEWAY_TIMEOUT; + TMH_trigger_daemon (); /* we resumed, kick MHD */ + return; + } + if (NULL == eh) + { + rc->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE; + rc->http_status = MHD_HTTP_BAD_GATEWAY; TMH_trigger_daemon (); /* we resumed, kick MHD */ return; } keys = TALER_EXCHANGE_get_keys (eh); if (NULL == keys) { - rc->ec = TALER_EC_KEYS_INVALID; - rc->http_status = MHD_HTTP_FAILED_DEPENDENCY; + rc->ec = TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE; + rc->http_status = MHD_HTTP_BAD_GATEWAY; TMH_trigger_daemon (); /* we resumed, kick MHD */ return; } if (NULL == payto_uri) { - rc->ec = TALER_EC_RESERVES_POST_UNSUPPORTED_WIRE_METHOD; + rc->ec = TALER_EC_MERCHANT_PRIVATE_POST_RESERVES_UNSUPPORTED_WIRE_METHOD; rc->http_status = MHD_HTTP_CONFLICT; TMH_trigger_daemon (); /* we resumed, kick MHD */ return; @@ -301,8 +308,8 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, if (qs < 0) return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_RESERVES_POST_DB_COMMIT_HARD_ERROR, - NULL); + TALER_EC_GENERIC_DB_STORE_FAILED, + "reserve"); return TALER_MHD_reply_json_pack (connection, MHD_HTTP_OK, "{s:o,s:s}", diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 92e3be36..178c609c 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -31,9 +31,9 @@ /** * How long to wait before giving up processing with the exchange? */ -#define TRANSFER_TIMEOUT (GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_SECONDS, \ - 30)) +#define TRANSFER_GENERIC_TIMEOUT (GNUNET_TIME_relative_multiply ( \ + GNUNET_TIME_UNIT_SECONDS, \ + 30)) /** * How often do we retry the simple INSERT database transaction? @@ -306,10 +306,11 @@ check_transfer (void *cls, " s:I, s:o, s:o, s:o, s:o," " s:o, s:o, s:o, s:o, s:o }", "code", - (json_int_t) TALER_EC_POST_TRANSFERS_CONFLICTING_REPORTS, + (json_int_t) + TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS, "hint", TALER_ErrorCode_get_hint ( - TALER_EC_POST_TRANSFERS_CONFLICTING_REPORTS), + TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_CONFLICTING_REPORTS), "exchange_url", exchange_url, "deposit_timestamp", @@ -404,9 +405,11 @@ check_wire_fee (struct PostTransfersContext *ptc, ptc->response = TALER_MHD_make_json_pack ( "{s:I, s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", - "code", (json_int_t) TALER_EC_POST_TRANSFERS_JSON_BAD_WIRE_FEE, + "code", + (json_int_t) TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE, "hint", - TALER_ErrorCode_get_hint (TALER_EC_POST_TRANSFERS_JSON_BAD_WIRE_FEE), + TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE), "wire_fee", TALER_JSON_from_amount (wire_fee), "execution_time", GNUNET_JSON_from_time_abs (execution_time), "expected_wire_fee", TALER_JSON_from_amount (&expected_fee), @@ -445,10 +448,11 @@ wire_transfer_cb (void *cls, { resume_transfer_with_response ( ptc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_BAD_GATEWAY, TALER_MHD_make_json_pack ( "{s:I, s:I, s:I, s:O}", - "code", (json_int_t) TALER_EC_POST_TRANSFERS_EXCHANGE_ERROR, + "code", + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_UNEXPECTED_STATUS, "exchange_code", (json_int_t) hr->ec, "exchange_http_status", (json_int_t) hr->http_status, "exchange_reply", hr->reply)); @@ -465,8 +469,8 @@ wire_transfer_cb (void *cls, GNUNET_break (0); resume_transfer_with_error (ptc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_STORE_TRANSFER_ERROR, - "could not start transaction"); + TALER_EC_GENERIC_DB_START_FAILED, + NULL); return; } /* Ok, exchange answer is acceptable, store it */ @@ -488,8 +492,8 @@ retry: resume_transfer_with_error ( ptc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_STORE_TRANSFER_ERROR, - "failed to commit transaction to local database"); + TALER_EC_GENERIC_DB_COMMIT_FAILED, + NULL); return; } if (0 <= qs) @@ -503,8 +507,8 @@ retry: resume_transfer_with_error ( ptc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_STORE_TRANSFER_ERROR, - "repeated serialization failures trying to commit transaction to local database"); + TALER_EC_GENERIC_DB_SOFT_FAILURE, + NULL); return; } @@ -538,20 +542,33 @@ process_transfer_with_exchange (void *cls, (void) payto_uri; (void) exchange_trusted; ptc->fo = NULL; - if (MHD_HTTP_OK != hr->http_status) + if (NULL == hr) + { + resume_transfer_with_response ( + ptc, + MHD_HTTP_GATEWAY_TIMEOUT, + TALER_MHD_make_json_pack ( + "{s:s, s:I}" + "hint", TALER_ErrorCode_get_hint ( + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT), + "code", + (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT)); + return; + } + if (NULL == eh) { /* The request failed somehow */ GNUNET_break_op (0); resume_transfer_with_response ( ptc, - MHD_HTTP_FAILED_DEPENDENCY, + MHD_HTTP_BAD_GATEWAY, TALER_MHD_make_json_pack ( (NULL != hr->reply) ? "{s:s, s:I, s:I, s:I, s:O}" : "{s:s, s:I, s:I, s:I}", "hint", TALER_ErrorCode_get_hint ( - TALER_EC_POST_TRANSFERS_EXCHANGE_KEYS_FAILURE), - "code", (json_int_t) TALER_EC_POST_TRANSFERS_EXCHANGE_KEYS_FAILURE, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE), + "code", (json_int_t) TALER_EC_MERCHANT_GENERIC_EXCHANGE_CONNECT_FAILURE, "exchange_http_status", (json_int_t) hr->http_status, "exchange_code", (json_int_t) hr->ec, "exchange_reply", hr->reply)); @@ -567,9 +584,9 @@ process_transfer_with_exchange (void *cls, { GNUNET_break (0); resume_transfer_with_error (ptc, - MHD_HTTP_FAILED_DEPENDENCY, - TALER_EC_POST_TRANSFERS_EXCHANGE_KEYS_FAILURE, - "failed to get keys"); + MHD_HTTP_BAD_GATEWAY, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_KEYS_FAILURE, + NULL); return; } ptc->master_pub = keys->master_pub; @@ -584,7 +601,7 @@ process_transfer_with_exchange (void *cls, GNUNET_break (0); resume_transfer_with_error (ptc, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_REQUEST_ERROR, + TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_REQUEST_ERROR, "failed to run GET /transfers/ on exchange"); } } @@ -631,8 +648,8 @@ verify_exchange_claim_cb (void *cls, GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); ptc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; ptc->response - = TALER_MHD_make_error (TALER_EC_POST_TRANSFERS_DB_FETCH_DEPOSIT_ERROR, - "failed to obtain deposit data from local database"); + = TALER_MHD_make_error (TALER_EC_GENERIC_DB_FETCH_FAILED, + "deposit by contract and coin"); return; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -651,8 +668,8 @@ verify_exchange_claim_cb (void *cls, GNUNET_break (0); ptc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; ptc->response = - TALER_MHD_make_error (TALER_EC_POST_TRANSFERS_DB_INTERNAL_LOGIC_ERROR, - "internal logic error"); + TALER_MHD_make_error (TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, + "check_transfer_result must not be NULL"); return; } if (GNUNET_SYSERR == ptc->check_transfer_result) @@ -807,9 +824,9 @@ handle_transfer_timeout (void *cls) ptc->wdh = NULL; } resume_transfer_with_error (ptc, - MHD_HTTP_SERVICE_UNAVAILABLE, - TALER_EC_POST_TRANSFERS_EXCHANGE_TIMEOUT, - "exchange not reachable"); + MHD_HTTP_GATEWAY_TIMEOUT, + TALER_EC_MERCHANT_GENERIC_EXCHANGE_TIMEOUT, + NULL); } @@ -926,8 +943,8 @@ queue: GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "transfer"); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) goto fetch; @@ -981,8 +998,8 @@ queue: GNUNET_CONTAINER_multihashmap_destroy (map); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_LOOKUP_ERROR, - NULL); + TALER_EC_GENERIC_DB_FETCH_FAILED, + "transfer summary"); } deposit_sums = json_array (); @@ -1020,8 +1037,8 @@ fetch: GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_POST_TRANSFERS_DB_STORE_ERROR, - NULL); + TALER_EC_GENERIC_DB_STORE_FAILED, + "transfer"); } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { @@ -1042,7 +1059,7 @@ fetch: ptc->hc->instance->settings.id); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_POST_TRANSFERS_ACCOUNT_NOT_FOUND, + TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_ACCOUNT_NOT_FOUND, ptc->payto_uri); } } @@ -1059,7 +1076,7 @@ fetch: &process_transfer_with_exchange, ptc); ptc->timeout_task - = GNUNET_SCHEDULER_add_delayed (TRANSFER_TIMEOUT, + = GNUNET_SCHEDULER_add_delayed (TRANSFER_GENERIC_TIMEOUT, &handle_transfer_timeout, ptc); return MHD_YES; diff --git a/src/backend/taler-merchant-httpd_statics.c b/src/backend/taler-merchant-httpd_statics.c index 48d00ce4..ea94d9bf 100644 --- a/src/backend/taler-merchant-httpd_statics.c +++ b/src/backend/taler-merchant-httpd_statics.c @@ -125,7 +125,7 @@ TMH_return_static (const struct TMH_RequestHandler *rh, hc->infix); return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_ENDPOINT_UNKNOWN, + TALER_EC_GENERIC_ENDPOINT_UNKNOWN, hc->infix); } diff --git a/src/backend/taler-merchant-httpd_templating.c b/src/backend/taler-merchant-httpd_templating.c index b604f6ba..393104dc 100644 --- a/src/backend/taler-merchant-httpd_templating.c +++ b/src/backend/taler-merchant-httpd_templating.c @@ -146,7 +146,7 @@ TMH_return_from_template (struct MHD_Connection *connection, if (MHD_YES != TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_ACCEPTABLE, - TALER_EC_MERCHANT_FAILED_TO_LOAD_TEMPLATE, + TALER_EC_MERCHANT_GENERIC_FAILED_TO_LOAD_TEMPLATE, template)) return GNUNET_SYSERR; return GNUNET_NO; @@ -164,7 +164,7 @@ TMH_return_from_template (struct MHD_Connection *connection, if (MHD_YES != TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_MERCHANT_FAILED_TO_EXPAND_TEMPLATE, + TALER_EC_MERCHANT_GENERIC_FAILED_TO_EXPAND_TEMPLATE, template)) return GNUNET_SYSERR; return GNUNET_NO; |