From 8f006e779e12fed604182faa096ebe6b5726d04d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 21:06:25 +0100 Subject: more refactoring for libtalermhd --- src/exchange/taler-exchange-httpd_db.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/exchange/taler-exchange-httpd_db.c') diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 37bd23792..19781f97f 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -23,6 +23,7 @@ #include #include #include "taler_json_lib.h" +#include "taler_mhd_lib.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -62,8 +63,10 @@ TEH_DB_know_coin_transaction (void *cls, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { *mhd_ret - = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_COIN_HISTORY_STORE_ERROR); + = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COIN_HISTORY_STORE_ERROR, + "could not persist coin data"); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -99,8 +102,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_SETUP_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_SETUP_FAILED, + "could not establish database session"); return GNUNET_SYSERR; } TEH_plugin->preflight (TEH_plugin->cls, @@ -117,8 +122,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_START_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_START_FAILED, + "could not begin transaction"); return GNUNET_SYSERR; } qs = cb (cb_cls, @@ -136,8 +143,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) - *mhd_ret = TEH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_HARD); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COMMIT_FAILED_HARD, + "could not commit database transaction"); return GNUNET_SYSERR; } /* make sure callback did not violate invariants! */ @@ -150,8 +159,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, name, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) - *mhd_ret = TEH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DB_COMMIT_FAILED_ON_RETRY, + "repatedly failed to serialize database transaction"); return GNUNET_SYSERR; } -- cgit v1.2.3