From e42cf1a738aef2c2aee32997d157965b02e2fe0d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 8 Nov 2020 00:50:16 +0100 Subject: adjust error codes in merchant --- src/backend/taler-merchant-httpd.c | 8 +- src/backend/taler-merchant-httpd_auditors.c | 9 +- src/backend/taler-merchant-httpd_exchanges.c | 4 +- src/backend/taler-merchant-httpd_get-orders-ID.c | 62 ++++---- src/backend/taler-merchant-httpd_get-tips-ID.c | 8 +- .../taler-merchant-httpd_post-orders-ID-abort.c | 91 ++++++------ .../taler-merchant-httpd_post-orders-ID-claim.c | 10 +- .../taler-merchant-httpd_post-orders-ID-paid.c | 20 +-- .../taler-merchant-httpd_post-orders-ID-pay.c | 163 +++++++++++---------- .../taler-merchant-httpd_post-orders-ID-refund.c | 101 +++++++++---- .../taler-merchant-httpd_post-tips-ID-pickup.c | 116 ++++++++++----- ...er-merchant-httpd_private-delete-instances-ID.c | 8 +- ...taler-merchant-httpd_private-delete-orders-ID.c | 8 +- ...ler-merchant-httpd_private-delete-products-ID.c | 15 +- ...ler-merchant-httpd_private-delete-reserves-ID.c | 8 +- .../taler-merchant-httpd_private-get-orders-ID.c | 82 ++++++----- .../taler-merchant-httpd_private-get-orders.c | 26 ++-- .../taler-merchant-httpd_private-get-products-ID.c | 4 +- .../taler-merchant-httpd_private-get-products.c | 2 +- .../taler-merchant-httpd_private-get-reserves-ID.c | 10 +- .../taler-merchant-httpd_private-get-reserves.c | 8 +- .../taler-merchant-httpd_private-get-tips-ID.c | 10 +- .../taler-merchant-httpd_private-get-tips.c | 10 +- .../taler-merchant-httpd_private-get-transfers.c | 14 +- ...ler-merchant-httpd_private-patch-instances-ID.c | 14 +- ...merchant-httpd_private-patch-orders-ID-forget.c | 18 +-- ...aler-merchant-httpd_private-patch-products-ID.c | 18 +-- .../taler-merchant-httpd_private-post-instances.c | 12 +- ...-merchant-httpd_private-post-orders-ID-refund.c | 32 ++-- .../taler-merchant-httpd_private-post-orders.c | 57 +++---- ...-merchant-httpd_private-post-products-ID-lock.c | 8 +- .../taler-merchant-httpd_private-post-products.c | 8 +- ...-httpd_private-post-reserves-ID-authorize-tip.c | 10 +- .../taler-merchant-httpd_private-post-reserves.c | 21 ++- .../taler-merchant-httpd_private-post-transfers.c | 93 +++++++----- src/backend/taler-merchant-httpd_statics.c | 2 +- src/backend/taler-merchant-httpd_templating.c | 4 +- src/backenddb/plugin_merchantdb_postgres.c | 51 ++++--- src/include/taler_merchant_service.h | 2 +- src/include/taler_merchantdb_plugin.h | 16 +- src/lib/merchant_api_common.c | 2 +- src/lib/merchant_api_get_config.c | 4 +- src/lib/merchant_api_get_instance.c | 2 +- src/lib/merchant_api_get_instances.c | 4 +- src/lib/merchant_api_get_orders.c | 4 +- src/lib/merchant_api_get_product.c | 2 +- src/lib/merchant_api_get_products.c | 4 +- src/lib/merchant_api_get_reserve.c | 8 +- src/lib/merchant_api_get_reserves.c | 8 +- src/lib/merchant_api_get_tips.c | 4 +- src/lib/merchant_api_get_transfers.c | 8 +- src/lib/merchant_api_lock_product.c | 2 +- src/lib/merchant_api_merchant_get_order.c | 20 +-- src/lib/merchant_api_merchant_get_tip.c | 4 +- src/lib/merchant_api_patch_instance.c | 2 +- src/lib/merchant_api_patch_order_forget.c | 2 +- src/lib/merchant_api_patch_product.c | 2 +- src/lib/merchant_api_post_instances.c | 2 +- src/lib/merchant_api_post_order_abort.c | 4 +- src/lib/merchant_api_post_order_claim.c | 4 +- src/lib/merchant_api_post_order_paid.c | 2 +- src/lib/merchant_api_post_order_pay.c | 6 +- src/lib/merchant_api_post_order_refund.c | 4 +- src/lib/merchant_api_post_orders.c | 28 ++-- src/lib/merchant_api_post_products.c | 2 +- src/lib/merchant_api_post_reserves.c | 4 +- src/lib/merchant_api_post_transfers.c | 8 +- src/lib/merchant_api_tip_authorize.c | 2 +- src/lib/merchant_api_tip_pickup.c | 2 +- src/lib/merchant_api_tip_pickup2.c | 2 +- src/lib/merchant_api_wallet_get_order.c | 6 +- src/lib/merchant_api_wallet_get_tip.c | 2 +- src/lib/merchant_api_wallet_post_order_refund.c | 12 +- src/testing/test_merchant_api.c | 8 +- 74 files changed, 754 insertions(+), 589 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; inum_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; @@ -214,6 +213,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 @@ -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; iactive = 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; diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 36e9ce82..6c87eea5 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -4350,13 +4350,13 @@ postgres_insert_reserve (void *cls, check_connection (pg); RETRY: if (MAX_RETRIES < ++retries) - return TALER_EC_TIP_PICKUP_DB_ERROR_SOFT; + return TALER_EC_GENERIC_DB_SOFT_FAILURE; if (GNUNET_OK != postgres_start (pg, "insert reserve")) { GNUNET_break (0); - return TALER_EC_TIP_PICKUP_DB_ERROR_HARD; + return TALER_EC_GENERIC_DB_START_FAILED; } /* Setup reserve */ @@ -5064,7 +5064,7 @@ lookup_reserve_for_tip_cb (void *cls, i)) { GNUNET_break (0); - lac->ec = TALER_EC_TIP_LOOKUP_RESERVE_DB_FAILURE; + lac->ec = TALER_EC_GENERIC_DB_FETCH_FAILED; return; } if (0 > @@ -5105,15 +5105,15 @@ lookup_reserve_for_tip_cb (void *cls, * @param[out] tip_id set to the unique ID for the tip * @param[out] expiration set to when the tip expires * @return transaction status, - * #TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired + * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired * #TALER_EC_TIP_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known - * #TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left - * #TALER_EC_TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_LOOKUP_RESERVE_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_RESERVE_INVARIANT_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_SERIALIZATION_FAILURE on soft DB errors (client should retry) + * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left + * #TALER_EC_GENERIC_DB_START_FAILED on hard DB errors + * #TALER_EC_GENERIC_DB_FETCH_FAILED on hard DB errors + * #TALER_EC_GENERIC_DB_STORE_FAILED on hard DB errors + * #TALER_EC_GENERIC_DB_INVARIANT_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_START_FAILED on hard DB errors + * #TALER_EC_GENERIC_DB_SOFT_FAILURE soft DB errors (client should retry) * #TALER_EC_NONE upon success */ static enum TALER_ErrorCode @@ -5144,14 +5144,15 @@ RETRY: if (MAX_RETRIES < ++retries) { GNUNET_break (0); - return TALER_EC_TIP_AUTHORIZE_DB_SERIALIZATION_FAILURE; + return + TALER_EC_GENERIC_DB_SOFT_FAILURE; } if (GNUNET_OK != postgres_start (pg, "enable tip reserve")) { GNUNET_break (0); - return TALER_EC_TIP_AUTHORIZE_DB_START_FAILURE; + return TALER_EC_GENERIC_DB_START_FAILED; } if (NULL == reserve_pubp) { @@ -5175,18 +5176,19 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_LOOKUP_RESERVE_FAILURE; + return + TALER_EC_GENERIC_DB_FETCH_FAILED; } if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us == lac.expiration.abs_value_us) { postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_RESERVE_NOT_FOUND; + return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND; } if (0 == GNUNET_TIME_absolute_get_remaining (lac.expiration).rel_value_us) { postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_RESERVE_EXPIRED; + return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED; } reserve_pubp = &lac.reserve_pub; } @@ -5220,13 +5222,14 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_LOOKUP_RESERVE_FAILURE; + return + TALER_EC_GENERIC_DB_FETCH_FAILED; } if (qs == 0) { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_RESERVE_NOT_FOUND; + return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND; } } { @@ -5239,14 +5242,15 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_RESERVE_INVARIANT_FAILURE; + return + TALER_EC_GENERIC_DB_INVARIANT_FAILURE; } if (0 > TALER_amount_cmp (&remaining, amount)) { postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS; + return TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS; } } GNUNET_assert (0 <= @@ -5273,7 +5277,8 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE; + return + TALER_EC_GENERIC_DB_STORE_FAILED; } } GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, @@ -5303,7 +5308,7 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE; + return TALER_EC_GENERIC_DB_STORE_FAILED; } } qs = postgres_commit (pg); @@ -5313,7 +5318,7 @@ RETRY: { GNUNET_break (0); postgres_rollback (pg); - return TALER_EC_TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE; + return TALER_EC_GENERIC_DB_COMMIT_FAILED; } return TALER_EC_NONE; } diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 88a33ba5..f7a8d667 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -110,7 +110,7 @@ struct TALER_MERCHANT_HttpResponse * error details and setup the corresponding @a hr structure. Internally * used to convert merchant's responses in to @a hr. * - * @param response if NULL we will report #TALER_EC_INVALID_RESPONSE in `ec` + * @param response if NULL we will report #TALER_EC_GENERIC_INVALID_RESPONSE in `ec` * @param http_status http status to use * @param[out] hr response object to initialize, fields will * only be valid as long as @a response is valid as well diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index ded914de..661e42dd 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -1873,15 +1873,15 @@ struct TALER_MERCHANTDB_Plugin * @param[out] tip_id set to the unique ID for the tip * @param[out] expiration set to when the tip expires * @return transaction status, - * #TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired + * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired * #TALER_EC_TIP_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known - * #TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left - * #TALER_EC_TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_LOOKUP_RESERVE_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_RESERVE_INVARIANT_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors - * #TALER_EC_TIP_AUTHORIZE_DB_SERIALIZATION_FAILURE on soft DB errors (client should retry) + * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left + * #TALER_EC_GENERIC_DB_START_FAILED__TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_FETCH_FAILED__TIP_AUTHORIZE_DB_LOOKUP_RESERVE_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_STORE_FAILED__TIP_AUTHORIZE_DB_UPDATE_RESERVE_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_INVARIANT_FAILURE__TIP_AUTHORIZE_DB_RESERVE_INVARIANT_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_START_FAILED__TIP_AUTHORIZE_DB_START_FAILURE on hard DB errors + * #TALER_EC_GENERIC_DB_SOFT_FAILURE__TIP_AUTHORIZE_DB_SERIALIZATION_FAILURE on soft DB errors (client should retry) * #TALER_EC_NONE upon success */ enum TALER_ErrorCode diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c index a06a6722..c2fbaa39 100644 --- a/src/lib/merchant_api_common.c +++ b/src/lib/merchant_api_common.c @@ -42,7 +42,7 @@ TALER_MERCHANT_parse_error_details_ (const json_t *response, hr->http_status = http_status; if (NULL == response) { - hr->ec = TALER_EC_INVALID_RESPONSE; + hr->ec = TALER_EC_GENERIC_INVALID_RESPONSE; return; } hr->ec = TALER_JSON_get_error_code (response); diff --git a/src/lib/merchant_api_get_config.c b/src/lib/merchant_api_get_config.c index bbf19329..b27e386c 100644 --- a/src/lib/merchant_api_get_config.c +++ b/src/lib/merchant_api_get_config.c @@ -120,7 +120,7 @@ handle_config_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -135,7 +135,7 @@ handle_config_finished (void *cls, &age)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { diff --git a/src/lib/merchant_api_get_instance.c b/src/lib/merchant_api_get_instance.c index ed208ba7..512d1b7c 100644 --- a/src/lib/merchant_api_get_instance.c +++ b/src/lib/merchant_api_get_instance.c @@ -191,7 +191,7 @@ handle_get_instance_finished (void *cls, } GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; GNUNET_JSON_parse_free (spec); break; } diff --git a/src/lib/merchant_api_get_instances.c b/src/lib/merchant_api_get_instances.c index ba2e5608..be8b6e5b 100644 --- a/src/lib/merchant_api_get_instances.c +++ b/src/lib/merchant_api_get_instances.c @@ -183,7 +183,7 @@ handle_instances_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -199,7 +199,7 @@ handle_instances_finished (void *cls, else { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); diff --git a/src/lib/merchant_api_get_orders.c b/src/lib/merchant_api_get_orders.c index d1f2843b..0b8a35f8 100644 --- a/src/lib/merchant_api_get_orders.c +++ b/src/lib/merchant_api_get_orders.c @@ -170,7 +170,7 @@ handle_get_orders_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -186,7 +186,7 @@ handle_get_orders_finished (void *cls, else { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); diff --git a/src/lib/merchant_api_get_product.c b/src/lib/merchant_api_get_product.c index 02560761..c88e74f9 100644 --- a/src/lib/merchant_api_get_product.c +++ b/src/lib/merchant_api_get_product.c @@ -169,7 +169,7 @@ handle_get_product_finished (void *cls, return; } hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; GNUNET_JSON_parse_free (spec); break; } diff --git a/src/lib/merchant_api_get_products.c b/src/lib/merchant_api_get_products.c index 47d45009..d5d57252 100644 --- a/src/lib/merchant_api_get_products.c +++ b/src/lib/merchant_api_get_products.c @@ -158,7 +158,7 @@ handle_get_products_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -174,7 +174,7 @@ handle_get_products_finished (void *cls, else { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); diff --git a/src/lib/merchant_api_get_reserve.c b/src/lib/merchant_api_get_reserve.c index bd88661f..429cccff 100644 --- a/src/lib/merchant_api_get_reserve.c +++ b/src/lib/merchant_api_get_reserve.c @@ -89,7 +89,7 @@ handle_reserve_get_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -120,7 +120,7 @@ handle_reserve_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } @@ -142,7 +142,7 @@ handle_reserve_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } { @@ -184,7 +184,7 @@ handle_reserve_get_finished (void *cls, GNUNET_break_op (0); GNUNET_free (tds); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } rgh->cb (rgh->cb_cls, diff --git a/src/lib/merchant_api_get_reserves.c b/src/lib/merchant_api_get_reserves.c index 524f3b68..52853065 100644 --- a/src/lib/merchant_api_get_reserves.c +++ b/src/lib/merchant_api_get_reserves.c @@ -88,7 +88,7 @@ handle_reserves_get_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -106,7 +106,7 @@ handle_reserves_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } else @@ -122,7 +122,7 @@ handle_reserves_get_finished (void *cls, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } rds_length = json_array_size (reserves); @@ -168,7 +168,7 @@ handle_reserves_get_finished (void *cls, GNUNET_free (rds); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } rgh->cb (rgh->cb_cls, diff --git a/src/lib/merchant_api_get_tips.c b/src/lib/merchant_api_get_tips.c index ada15952..16a87fff 100644 --- a/src/lib/merchant_api_get_tips.c +++ b/src/lib/merchant_api_get_tips.c @@ -162,7 +162,7 @@ handle_get_tips_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -178,7 +178,7 @@ handle_get_tips_finished (void *cls, else { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); diff --git a/src/lib/merchant_api_get_transfers.c b/src/lib/merchant_api_get_transfers.c index 90dce5d5..0bfd9990 100644 --- a/src/lib/merchant_api_get_transfers.c +++ b/src/lib/merchant_api_get_transfers.c @@ -88,7 +88,7 @@ handle_transfers_get_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -106,7 +106,7 @@ handle_transfers_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } else @@ -122,7 +122,7 @@ handle_transfers_get_finished (void *cls, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } tds_length = json_array_size (transfers); @@ -171,7 +171,7 @@ handle_transfers_get_finished (void *cls, GNUNET_free (tds); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } gth->cb (gth->cb_cls, diff --git a/src/lib/merchant_api_lock_product.c b/src/lib/merchant_api_lock_product.c index 906ca68c..27f4f6e5 100644 --- a/src/lib/merchant_api_lock_product.c +++ b/src/lib/merchant_api_lock_product.c @@ -98,7 +98,7 @@ handle_lock_product_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_merchant_get_order.c b/src/lib/merchant_api_merchant_get_order.c index 62510a6c..9504d16b 100644 --- a/src/lib/merchant_api_merchant_get_order.c +++ b/src/lib/merchant_api_merchant_get_order.c @@ -87,7 +87,7 @@ handle_unpaid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -135,7 +135,7 @@ handle_claimed (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -201,7 +201,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -214,7 +214,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -257,7 +257,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -277,7 +277,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, GNUNET_JSON_spec_uint32 ("code", &c32), GNUNET_JSON_spec_string ("hint", - &wr->hint), + &wr->hint), GNUNET_JSON_spec_uint32 ("exchange_ec", &eec32), GNUNET_JSON_spec_uint32 ("exchange_hc", @@ -294,7 +294,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -328,7 +328,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh, { GNUNET_break_op (0); hr->http_status = 0; - hr->ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr->ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, hr, NULL); @@ -407,7 +407,7 @@ handle_merchant_order_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, &hr, NULL); @@ -434,7 +434,7 @@ handle_merchant_order_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_MERCHANT_ORDER_GET_REPLY_MALFORMED; + hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; omgh->cb (omgh->cb_cls, &hr, NULL); diff --git a/src/lib/merchant_api_merchant_get_tip.c b/src/lib/merchant_api_merchant_get_tip.c index 09c9fb76..4d4c66f7 100644 --- a/src/lib/merchant_api_merchant_get_tip.c +++ b/src/lib/merchant_api_merchant_get_tip.c @@ -171,7 +171,7 @@ handle_merchant_tip_get_finished (void *cls, NULL, NULL)) { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } else { @@ -206,7 +206,7 @@ handle_merchant_tip_get_finished (void *cls, else { hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } } GNUNET_JSON_parse_free (spec); diff --git a/src/lib/merchant_api_patch_instance.c b/src/lib/merchant_api_patch_instance.c index d63aef71..7e38b23b 100644 --- a/src/lib/merchant_api_patch_instance.c +++ b/src/lib/merchant_api_patch_instance.c @@ -98,7 +98,7 @@ handle_patch_instance_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_patch_order_forget.c b/src/lib/merchant_api_patch_order_forget.c index 1a7a6c64..b00361fc 100644 --- a/src/lib/merchant_api_patch_order_forget.c +++ b/src/lib/merchant_api_patch_order_forget.c @@ -98,7 +98,7 @@ handle_forget_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: break; diff --git a/src/lib/merchant_api_patch_product.c b/src/lib/merchant_api_patch_product.c index 4d456c5a..e7d22520 100644 --- a/src/lib/merchant_api_patch_product.c +++ b/src/lib/merchant_api_patch_product.c @@ -98,7 +98,7 @@ handle_patch_product_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_post_instances.c b/src/lib/merchant_api_post_instances.c index 7b19c25b..1d52f053 100644 --- a/src/lib/merchant_api_post_instances.c +++ b/src/lib/merchant_api_post_instances.c @@ -98,7 +98,7 @@ handle_post_instances_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_post_order_abort.c b/src/lib/merchant_api_post_order_abort.c index d8489d84..4e8a508e 100644 --- a/src/lib/merchant_api_post_order_abort.c +++ b/src/lib/merchant_api_post_order_abort.c @@ -243,7 +243,7 @@ handle_abort_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: if (GNUNET_OK == @@ -254,7 +254,7 @@ handle_abort_finished (void *cls, return; } hr.http_status = 0; - hr.ec = TALER_EC_PAY_MERCHANT_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_BAD_REQUEST: hr.ec = TALER_JSON_get_error_code (json); diff --git a/src/lib/merchant_api_post_order_claim.c b/src/lib/merchant_api_post_order_claim.c index ab7d26b8..80c4949a 100644 --- a/src/lib/merchant_api_post_order_claim.c +++ b/src/lib/merchant_api_post_order_claim.c @@ -127,7 +127,7 @@ handle_post_order_claim_finished (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Claiming order failed: could not parse JSON response\n"); GNUNET_break_op (0); - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; hr.http_status = 0; och->cb (och->cb_cls, &hr, @@ -143,7 +143,7 @@ handle_post_order_claim_finished (void *cls, &hash)) { GNUNET_break (0); - hr.ec = TALER_EC_CLIENT_INTERNAL_FAILURE; + hr.ec = TALER_EC_MERCHANT_POST_ORDERS_ID_CLAIM_CLIENT_INTERNAL_FAILURE; hr.http_status = 0; GNUNET_JSON_parse_free (spec); och->cb (och->cb_cls, diff --git a/src/lib/merchant_api_post_order_paid.c b/src/lib/merchant_api_post_order_paid.c index 5424ad8b..cdb4ae23 100644 --- a/src/lib/merchant_api_post_order_paid.c +++ b/src/lib/merchant_api_post_order_paid.c @@ -100,7 +100,7 @@ handle_paid_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_post_order_pay.c b/src/lib/merchant_api_post_order_pay.c index 783b84f3..1088074c 100644 --- a/src/lib/merchant_api_post_order_pay.c +++ b/src/lib/merchant_api_post_order_pay.c @@ -258,7 +258,7 @@ handle_pay_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: if (oph->am_wallet) @@ -281,7 +281,7 @@ handle_pay_finished (void *cls, NULL, NULL)) { GNUNET_break_op (0); - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; hr.http_status = 0; hr.hint = "sig field missing in response"; break; @@ -294,7 +294,7 @@ handle_pay_finished (void *cls, &oph->merchant_pub.eddsa_pub)) { GNUNET_break_op (0); - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; hr.http_status = 0; hr.hint = "signature invalid"; } diff --git a/src/lib/merchant_api_post_order_refund.c b/src/lib/merchant_api_post_order_refund.c index c40fb7a7..748fb8c1 100644 --- a/src/lib/merchant_api_post_order_refund.c +++ b/src/lib/merchant_api_post_order_refund.c @@ -92,7 +92,7 @@ handle_refund_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; orh->cb (orh->cb_cls, &hr, NULL, @@ -117,7 +117,7 @@ handle_refund_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; orh->cb (orh->cb_cls, &hr, NULL, diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c index 9c45ad2c..56de86d1 100644 --- a/src/lib/merchant_api_post_orders.c +++ b/src/lib/merchant_api_post_orders.c @@ -92,12 +92,12 @@ handle_post_order_finished (void *cls, .hr.reply = json }; struct TALER_ClaimTokenP token = {0}; - + po->job = NULL; switch (response_code) { case 0: - por.hr.ec = TALER_EC_INVALID_RESPONSE; + por.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -109,7 +109,7 @@ handle_post_order_finished (void *cls, &token)), GNUNET_JSON_spec_end () }; - + if (GNUNET_OK != GNUNET_JSON_parse (json, spec, @@ -117,7 +117,7 @@ handle_post_order_finished (void *cls, { GNUNET_break_op (0); por.hr.http_status = 0; - por.hr.ec = TALER_EC_PROPOSAL_REPLY_MALFORMED; + por.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; } else { @@ -157,21 +157,21 @@ handle_post_order_finished (void *cls, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ( - "product_id", - &por.details.gone.product_id), + "product_id", + &por.details.gone.product_id), GNUNET_JSON_spec_uint64 ( - "requested_quantity", - &por.details.gone.requested_quantity), + "requested_quantity", + &por.details.gone.requested_quantity), GNUNET_JSON_spec_uint64 ( - "available_quantity", - &por.details.gone.available_quantity), + "available_quantity", + &por.details.gone.available_quantity), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_absolute_time ( - "restock_expected", - &por.details.gone.restock_expected)), + "restock_expected", + &por.details.gone.restock_expected)), GNUNET_JSON_spec_end () }; - + if (GNUNET_OK != GNUNET_JSON_parse (json, spec, @@ -179,7 +179,7 @@ handle_post_order_finished (void *cls, { GNUNET_break_op (0); por.hr.http_status = 0; - por.hr.ec = TALER_EC_PROPOSAL_REPLY_MALFORMED; + por.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; } break; } diff --git a/src/lib/merchant_api_post_products.c b/src/lib/merchant_api_post_products.c index 64360594..ed1d3899 100644 --- a/src/lib/merchant_api_post_products.c +++ b/src/lib/merchant_api_post_products.c @@ -98,7 +98,7 @@ handle_post_products_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NO_CONTENT: break; diff --git a/src/lib/merchant_api_post_reserves.c b/src/lib/merchant_api_post_reserves.c index 59ae0efe..149ecaeb 100644 --- a/src/lib/merchant_api_post_reserves.c +++ b/src/lib/merchant_api_post_reserves.c @@ -93,7 +93,7 @@ handle_post_reserves_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -114,7 +114,7 @@ handle_post_reserves_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } else diff --git a/src/lib/merchant_api_post_transfers.c b/src/lib/merchant_api_post_transfers.c index 5d35f6e8..14a44971 100644 --- a/src/lib/merchant_api_post_transfers.c +++ b/src/lib/merchant_api_post_transfers.c @@ -93,7 +93,7 @@ handle_post_transfers_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { @@ -120,7 +120,7 @@ handle_post_transfers_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } else @@ -136,7 +136,7 @@ handle_post_transfers_finished (void *cls, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } deposit_sums_length = json_array_size (deposit_sums); @@ -172,7 +172,7 @@ handle_post_transfers_finished (void *cls, GNUNET_free (details); GNUNET_JSON_parse_free (spec); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } pth->cb (pth->cb_cls, diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c index 57f2e2c0..64aad420 100644 --- a/src/lib/merchant_api_tip_authorize.c +++ b/src/lib/merchant_api_tip_authorize.c @@ -159,7 +159,7 @@ handle_tip_authorize_finished (void *cls, } GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_NOT_FOUND: /* Well-defined status code, pass on to application! */ diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c index 9cd5fb52..5f27b93b 100644 --- a/src/lib/merchant_api_tip_pickup.c +++ b/src/lib/merchant_api_tip_pickup.c @@ -151,7 +151,7 @@ pickup_done_cb (void *cls, struct TALER_MERCHANT_HttpResponse hrx = { .reply = hr->reply, .http_status = 0, - .ec = TALER_EC_TIP_PICKUP_UNBLIND_FAILURE + .ec = TALER_EC_MERCHANT_TIP_PICKUP_UNBLIND_FAILURE }; tp->cb (tp->cb_cls, diff --git a/src/lib/merchant_api_tip_pickup2.c b/src/lib/merchant_api_tip_pickup2.c index 1f12b3fc..f32a6feb 100644 --- a/src/lib/merchant_api_tip_pickup2.c +++ b/src/lib/merchant_api_tip_pickup2.c @@ -179,7 +179,7 @@ handle_tip_pickup_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; } break; case MHD_HTTP_INTERNAL_SERVER_ERROR: diff --git a/src/lib/merchant_api_wallet_get_order.c b/src/lib/merchant_api_wallet_get_order.c index 1866fc66..5979e69f 100644 --- a/src/lib/merchant_api_wallet_get_order.c +++ b/src/lib/merchant_api_wallet_get_order.c @@ -79,7 +79,7 @@ cb_failure (struct TALER_MERCHANT_OrderWalletGetHandle *owgh, const json_t *reply) { struct TALER_MERCHANT_HttpResponse hr = { - .ec = TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + .ec = ec, .reply = reply }; @@ -138,7 +138,7 @@ handle_wallet_get_order_finished (void *cls, { GNUNET_break_op (0); cb_failure (owgh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); TALER_MERCHANT_wallet_order_get_cancel (owgh); return; @@ -166,7 +166,7 @@ handle_wallet_get_order_finished (void *cls, { GNUNET_break_op (0); cb_failure (owgh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); } else diff --git a/src/lib/merchant_api_wallet_get_tip.c b/src/lib/merchant_api_wallet_get_tip.c index df454006..c6a6039d 100644 --- a/src/lib/merchant_api_wallet_get_tip.c +++ b/src/lib/merchant_api_wallet_get_tip.c @@ -112,7 +112,7 @@ handle_wallet_tip_get_finished (void *cls, { GNUNET_break_op (0); hr.http_status = 0; - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } tgh->cb (tgh->cb_cls, diff --git a/src/lib/merchant_api_wallet_post_order_refund.c b/src/lib/merchant_api_wallet_post_order_refund.c index ad56b6d3..c527696b 100644 --- a/src/lib/merchant_api_wallet_post_order_refund.c +++ b/src/lib/merchant_api_wallet_post_order_refund.c @@ -82,7 +82,7 @@ cb_failure (struct TALER_MERCHANT_WalletOrderRefundHandle *orh, const json_t *reply) { struct TALER_MERCHANT_HttpResponse hr = { - .ec = TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + .ec = ec, .reply = reply }; @@ -119,7 +119,7 @@ handle_refund_finished (void *cls, switch (response_code) { case 0: - hr.ec = TALER_EC_INVALID_RESPONSE; + hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; orh->cb (orh->cb_cls, &hr, NULL, @@ -150,7 +150,7 @@ handle_refund_finished (void *cls, { GNUNET_break_op (0); cb_failure (orh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); TALER_MERCHANT_wallet_post_order_refund_cancel (orh); return; @@ -160,7 +160,7 @@ handle_refund_finished (void *cls, { GNUNET_break_op (0); cb_failure (orh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); GNUNET_JSON_parse_free (spec); TALER_MERCHANT_wallet_post_order_refund_cancel (orh); @@ -195,7 +195,7 @@ handle_refund_finished (void *cls, { GNUNET_break_op (0); cb_failure (orh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); TALER_MERCHANT_wallet_post_order_refund_cancel (orh); return; @@ -282,7 +282,7 @@ handle_refund_finished (void *cls, { GNUNET_break_op (0); cb_failure (orh, - TALER_EC_CHECK_PAYMENT_RESPONSE_MALFORMED, + TALER_EC_GENERIC_REPLY_MALFORMED, json); TALER_MERCHANT_wallet_post_order_refund_cancel (orh); return; diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c index 2cb9caff..a5f0889d 100644 --- a/src/testing/test_merchant_api.c +++ b/src/testing/test_merchant_api.c @@ -938,7 +938,7 @@ run (void *cls, MHD_HTTP_BAD_REQUEST, "authorize-tip-1", pickup_amounts_1, - TALER_EC_TIP_PICKUP_AMOUNT_EXCEEDS_TIP_REMAINING), + TALER_EC_MERCHANT_TIP_PICKUP_AMOUNT_EXCEEDS_TIP_REMAINING), TALER_TESTING_cmd_tip_pickup ("pickup-tip-4", merchant_url, @@ -966,7 +966,7 @@ run (void *cls, MHD_HTTP_NOT_FOUND, "tip 3", "EUR:5.01", - TALER_EC_TIP_AUTHORIZE_DB_RESERVE_NOT_FOUND), + TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND), // Test reserve with insufficient funds TALER_TESTING_cmd_merchant_post_reserves ("create-reserve-tip-2", @@ -991,7 +991,7 @@ run (void *cls, MHD_HTTP_PRECONDITION_FAILED, "tip 4", "EUR:5.01", - TALER_EC_TIP_AUTHORIZE_INSUFFICIENT_FUNDS), + TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS), TALER_TESTING_cmd_tip_authorize_fake ("fake-tip-authorization"), TALER_TESTING_cmd_tip_pickup_with_ec ("pickup-non-existent-id", @@ -999,7 +999,7 @@ run (void *cls, MHD_HTTP_NOT_FOUND, "fake-tip-authorization", pickup_amounts_1, - TALER_EC_TIP_PICKUP_TIP_ID_UNKNOWN), + TALER_EC_MERCHANT_GENERIC_TIP_ID_UNKNOWN), TALER_TESTING_cmd_merchant_get_reserves ("get-reserves-2", merchant_url, -- cgit v1.2.3