gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: clean up GET /private/orders han


From: gnunet
Subject: [taler-merchant] branch master updated: clean up GET /private/orders handling
Date: Sat, 15 Aug 2020 23:53:11 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 61b2060  clean up GET /private/orders handling
61b2060 is described below

commit 61b206043a2adc2240828ae5d6b2d1c314786253
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Aug 15 23:53:09 2020 +0200

    clean up GET /private/orders handling
---
 .../taler-merchant-httpd_private-get-orders.c      | 53 ++++++++++------------
 1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c 
b/src/backend/taler-merchant-httpd_private-get-orders.c
index 1b245b8..b98b3b7 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders.c
@@ -39,14 +39,10 @@ struct AddOrderState
   const char *instance_id;
 
   /**
-   * The result after adding the orders (0 for okay, anything else for an 
error).
+   * The result after adding the orders (#TALER_EC_NONE for okay, anything 
else for an error).
    */
-  int result;
+  enum TALER_ErrorCode result;
 
-  /**
-   * In the case of an error, what message to respond with.
-   */
-  const char *ec_msg;
 };
 
 
@@ -276,8 +272,7 @@ add_order (void *cls,
       paid = false;
     if (qs < 0)
     {
-      aos->result = 1;
-      aos->ec_msg = "failed to lookup order status in database";
+      aos->result = 
TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_STATUS_DB_LOOKUP_ERROR;
       return;
     }
   }
@@ -304,8 +299,7 @@ add_order (void *cls,
 
   if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
   {
-    aos->result = 1;
-    aos->ec_msg = "failed to lookup order in database";
+    aos->result = 
TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_CONTRACT_DB_LOOKUP_ERROR;
     json_decref (contract_terms);
     return;
   }
@@ -329,8 +323,7 @@ add_order (void *cls,
                            spec,
                            NULL, NULL))
     {
-      aos->result = 1;
-      aos->ec_msg = "failed to parse order contract terms";
+      aos->result = TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_PARSE_CONTRACT_ERROR;
       json_decref (contract_terms);
       return;
     }
@@ -350,8 +343,8 @@ add_order (void *cls,
                                             &refund_amount);
       if (0 > qs)
       {
-        aos->result = 1;
-        aos->ec_msg = "failed to lookup order refunds in database";
+        aos->result =
+          TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_REFUND_DB_LOOKUP_ERROR;
         json_decref (contract_terms);
         return;
       }
@@ -476,13 +469,15 @@ TMH_private_get_orders (const struct TMH_RequestHandler 
*rh,
     /* resumed from long-polling, return answer we already have
        in 'hc->ctx' */
     struct AddOrderState *aos = hc->ctx;
-    if (0 != aos->result)
+
+    if (TALER_EC_NONE != aos->result)
     {
       GNUNET_break (0);
-      return TALER_MHD_reply_with_error (connection,
-                                         MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                         TALER_EC_ORDERS_GET_DB_LOOKUP_ERROR,
-                                         aos->ec_msg);
+      return TALER_MHD_reply_with_error (
+        connection,
+        MHD_HTTP_INTERNAL_SERVER_ERROR,
+        aos->result,
+        TALER_ErrorCode_get_hint (aos->result));
     }
     return TALER_MHD_reply_json_pack (connection,
                                       MHD_HTTP_OK,
@@ -625,7 +620,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh,
   GNUNET_assert (NULL != aos);
   aos->pa = json_array ();
   aos->instance_id = hc->instance->settings.id;
-  aos->result = 0;
+  aos->result = TALER_EC_NONE;
   GNUNET_assert (NULL != aos->pa);
   {
     qs = TMH_db->lookup_orders (TMH_db->cls,
@@ -633,21 +628,23 @@ TMH_private_get_orders (const struct TMH_RequestHandler 
*rh,
                                 &of,
                                 &add_order,
                                 aos);
-    if ((0 > qs) ||
-        (0 != aos->result))
+    if (0 > qs)
+    {
+      aos->result =
+        TALER_EC_MERCHANT_PRIVATE_GET_ORDERS_BY_FILTER_DB_LOOKUP_ERROR;
+    }
+    if (TALER_EC_NONE != aos->result)
     {
-      int aos_result = aos->result;
-      const char *aos_ec_msg = aos->ec_msg;
+      enum TALER_ErrorCode aos_result = aos->result;
 
       GNUNET_break (0);
       json_decref (aos->pa);
       GNUNET_free (aos);
       return TALER_MHD_reply_with_error (connection,
                                          MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                         TALER_EC_ORDERS_GET_DB_LOOKUP_ERROR,
-                                         0 != aos_result ?
-                                         aos_ec_msg :
-                                         "failed to lookup orders in 
database");
+                                         aos_result,
+                                         TALER_ErrorCode_get_hint (
+                                           aos_result));
     }
   }
   if ( (0 == qs) &&

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]