improve error reporting (#6969)

This commit is contained in:
Christian Grothoff 2021-08-03 14:08:45 +02:00
parent 0ce92c8402
commit 9da05a1901
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 63 additions and 18 deletions

View File

@ -181,10 +181,20 @@ credit_history_cb (void *cls,
(TALER_EC_NONE != ec) || (TALER_EC_NONE != ec) ||
(NULL == details) ) (NULL == details) )
{ {
fprintf (stderr, if (0 == http_status)
"Failed to obtain credit history: %u/%d\n", {
http_status, fprintf (stderr,
ec); "Failed to obtain HTTP reply from `%s'\n",
auth.wire_gateway_url);
}
else
{
fprintf (stderr,
"Failed to obtain credit history from `%s': HTTP status %u (%s)\n",
auth.wire_gateway_url,
http_status,
TALER_ErrorCode_get_hint (ec));
}
if (NULL != json) if (NULL != json)
json_dumpf (json, json_dumpf (json,
stderr, stderr,
@ -277,16 +287,27 @@ debit_history_cb (void *cls,
{ {
(void) cls; (void) cls;
dhh = NULL;
if (MHD_HTTP_OK != http_status) if (MHD_HTTP_OK != http_status)
{ {
if ( (MHD_HTTP_NO_CONTENT != http_status) || if ( (MHD_HTTP_NO_CONTENT != http_status) ||
(TALER_EC_NONE != ec) || (TALER_EC_NONE != ec) ||
(NULL == details) ) (NULL == details) )
{ {
fprintf (stderr, if (0 == http_status)
"Failed to obtain debit history: %u/%d\n", {
http_status, fprintf (stderr,
ec); "Failed to obtain HTTP reply from `%s'\n",
auth.wire_gateway_url);
}
else
{
fprintf (stderr,
"Failed to obtain debit history from `%s': HTTP status %u (%s)\n",
auth.wire_gateway_url,
http_status,
TALER_ErrorCode_get_hint (ec));
}
if (NULL != json) if (NULL != json)
json_dumpf (json, json_dumpf (json,
stderr, stderr,

View File

@ -42,6 +42,25 @@ static int connection_close;
*/ */
static int ret; static int ret;
/**
* Handle for the service.
*/
static struct TALER_FAKEBANK_Handle *fb;
/**
* Stop the process.
*
* @param cls NULL
*/
static void
do_shutdown (void *cls)
{
(void) cls;
TALER_FAKEBANK_stop (fb);
fb = NULL;
}
/** /**
* Main function that will be run. * Main function that will be run.
@ -69,7 +88,7 @@ run (void *cls,
TALER_config_get_currency (cfg, TALER_config_get_currency (cfg,
&currency_string)) &currency_string))
{ {
ret = 1; ret = EXIT_NOTCONFIGURED;
return; return;
} }
if (GNUNET_OK != if (GNUNET_OK !=
@ -92,15 +111,20 @@ run (void *cls,
"Maximum transaction history in RAM set to default of %llu\n", "Maximum transaction history in RAM set to default of %llu\n",
ram); ram);
} }
if (NULL == fb = TALER_FAKEBANK_start2 ((uint16_t) port,
TALER_FAKEBANK_start2 ((uint16_t) port, currency_string,
currency_string, ram,
ram, num_threads,
num_threads, (0 != connection_close));
(0 != connection_close) )) if (NULL == fb)
ret = 1; {
ret = EXIT_FAILURE;
return;
}
GNUNET_free (currency_string); GNUNET_free (currency_string);
ret = 0; GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
ret = EXIT_SUCCESS;
} }
@ -135,6 +159,6 @@ main (int argc,
options, options,
&run, &run,
NULL)) NULL))
return 1; return EXIT_INVALIDARGUMENT;
return ret; return ret;
} }