From 6eb32a65bf67438159fb1b6e3cf404b8721784ee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 5 Jul 2020 16:32:15 +0200 Subject: fix error reporting/handling --- src/exchange-tools/taler-exchange-keyup.c | 12 ++++++------ src/exchange/taler-exchange-httpd.c | 14 ++++++++++---- src/exchange/taler-exchange-httpd_wire.c | 4 ++++ src/exchangedb/plugin_exchangedb_postgres.c | 12 +++++++++++- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index a3e3bce29..0ea661d49 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -1016,9 +1016,9 @@ create_wire_fee_for_method (void *cls, af->wire_fee.currency)) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Invalid or missing amount in `%s' under `%s'\n", - section, - opt); + "Invalid or missing amount for option `%s' in section `%s'\n", + opt, + section); *ret = GNUNET_SYSERR; GNUNET_free (opt); break; @@ -1038,9 +1038,9 @@ create_wire_fee_for_method (void *cls, af->closing_fee.currency)) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Invalid or missing amount in `%s' under `%s'\n", - section, - opt); + "Invalid or missing amount for option `%s' in section `%s'\n", + opt, + section); *ret = GNUNET_SYSERR; GNUNET_free (opt); break; diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 00932c0f0..df01b01be 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -827,8 +827,8 @@ exchange_serve_process_config (void) &TEH_master_public_key. eddsa_pub)) { - fprintf (stderr, - "Invalid master public key given in exchange configuration."); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Invalid master public key given in exchange configuration."); GNUNET_free (master_public_key_str); return GNUNET_SYSERR; } @@ -840,14 +840,18 @@ exchange_serve_process_config (void) if (GNUNET_OK != TEH_WIRE_init (TEH_cfg)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to setup wire subsystem\n"); return GNUNET_SYSERR; + } if (NULL == (TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg))) { - fprintf (stderr, - "Failed to initialize DB subsystem\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to initialize DB subsystem\n"); TEH_WIRE_done (); return GNUNET_SYSERR; } @@ -859,6 +863,8 @@ exchange_serve_process_config (void) &serve_unixpath, &unixpath_mode)) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to setup HTTPd subsystem\n"); TEH_WIRE_done (); return GNUNET_SYSERR; } diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index 38bbad4ad..471fa4fad 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -341,6 +341,8 @@ TEH_WIRE_init (const struct GNUNET_CONFIGURATION_Handle *cfg) &ret); if (GNUNET_OK != ret) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Error setting up bank accounts\n"); TEH_WIRE_done (); return GNUNET_SYSERR; } @@ -349,6 +351,8 @@ TEH_WIRE_init (const struct GNUNET_CONFIGURATION_Handle *cfg) (0 == json_object_size (wire_fee_object)) ) { TEH_WIRE_done (); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "No bank accounts configured\n"); return GNUNET_SYSERR; } wire_methods = json_pack ("{s:O, s:O, s:o}", diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 93577feb4..641cbbef1 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1812,8 +1812,12 @@ postgres_iterate_denomination_info (void *cls, .cb_cls = cb_cls, .pg = pc }; + struct TALER_EXCHANGEDB_Session *session; - return GNUNET_PQ_eval_prepared_multi_select (postgres_get_session (pc)->conn, + session = postgres_get_session (pc); + if (NULL == session) + return GNUNET_DB_STATUS_HARD_ERROR; + return GNUNET_PQ_eval_prepared_multi_select (session->conn, "denomination_iterate", params, &domination_cb_helper, @@ -3068,6 +3072,8 @@ postgres_get_known_coin (void *cls, coin_info->coin_pub = *coin_pub; if (NULL == session) session = postgres_get_session (pc); + if (NULL == session) + return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, "get_known_coin", params, @@ -3107,6 +3113,8 @@ postgres_get_coin_denomination ( TALER_B2S (coin_pub)); if (NULL == session) session = postgres_get_session (pc); + if (NULL == session) + return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, "get_coin_denomination", params, @@ -3475,6 +3483,8 @@ postgres_get_melt (void *cls, melt->session.coin.denom_sig.rsa_signature = NULL; if (NULL == session) session = postgres_get_session (pg); + if (NULL == session) + return GNUNET_DB_STATUS_HARD_ERROR; qs = GNUNET_PQ_eval_prepared_singleton_select (session->conn, "get_melt", params, -- cgit v1.2.3