summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-07-21 15:48:11 +0200
committerFlorian Dold <florian@dold.me>2021-07-21 15:48:20 +0200
commitba2d435ec00465d7235cbe26b958e22be70a87c5 (patch)
tree696ad7c2fad7c637b5e2c85c9414be5a0e8723e7 /src
parent4c184f7e685817b565013c3afb2a5c30ecf10161 (diff)
downloadmerchant-ba2d435ec00465d7235cbe26b958e22be70a87c5.tar.gz
merchant-ba2d435ec00465d7235cbe26b958e22be70a87c5.tar.bz2
merchant-ba2d435ec00465d7235cbe26b958e22be70a87c5.zip
improve error handling in lookup_products
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-products.c2
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c15
2 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-products.c b/src/backend/taler-merchant-httpd_private-get-products.c
index 9d8b40f8..fb9b2192 100644
--- a/src/backend/taler-merchant-httpd_private-get-products.c
+++ b/src/backend/taler-merchant-httpd_private-get-products.c
@@ -45,7 +45,7 @@ add_product (void *cls,
/**
- * Handle a GET "/products" request.
+ * Handle a GET "/private/products" request.
*
* @param rh context of the handler
* @param connection the MHD connection to handle
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 54a7241b..6d272d05 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -895,9 +895,9 @@ struct LookupProductsContext
void *cb_cls;
/**
- * Internal result.
+ * Did database result extraction fail?
*/
- enum GNUNET_DB_QueryStatus qs;
+ bool extract_failed;
};
@@ -931,7 +931,7 @@ lookup_products_cb (void *cls,
i))
{
GNUNET_break (0);
- plc->qs = GNUNET_DB_STATUS_HARD_ERROR;
+ plc->extract_failed = true;
return;
}
plc->cb (plc->cb_cls,
@@ -959,7 +959,9 @@ postgres_lookup_products (void *cls,
struct PostgresClosure *pg = cls;
struct LookupProductsContext plc = {
.cb = cb,
- .cb_cls = cb_cls
+ .cb_cls = cb_cls,
+ /* Can be overwritten by the lookup_products_cb */
+ .extract_failed = false,
};
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (instance_id),
@@ -972,8 +974,9 @@ postgres_lookup_products (void *cls,
params,
&lookup_products_cb,
&plc);
- if (0 != plc.qs)
- return plc.qs;
+ /* If there was an error inside lookup_products_cb, return a hard error. */
+ if (plc.extract_failed)
+ return GNUNET_DB_STATUS_HARD_ERROR;
return qs;
}