gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 119/277: better error handling


From: gnunet
Subject: [taler-merchant] 119/277: better error handling
Date: Sun, 05 Jul 2020 20:50:32 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

commit 7d83b800d2aeb814032ae69007290f69aace42c3
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon May 18 19:28:45 2020 +0200

    better error handling
---
 src/backend/taler-merchant-httpd_exchanges.c       |  2 +-
 .../taler-merchant-httpd_private-post-reserves.c   | 38 ++++++++++++++++++----
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index 24b5202..c6e7ca7 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -656,7 +656,7 @@ handle_wire_data (void *cls,
     {
       fo->fc (fo->fc_cls,
               hr,
-              NULL,
+              exchange->conn,
               NULL,
               NULL,
               GNUNET_NO);
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c 
b/src/backend/taler-merchant-httpd_private-post-reserves.c
index abb6d0b..0c62ce7 100644
--- a/src/backend/taler-merchant-httpd_private-post-reserves.c
+++ b/src/backend/taler-merchant-httpd_private-post-reserves.c
@@ -84,6 +84,16 @@ struct PostReserveContext
    */
   struct GNUNET_TIME_Absolute reserve_expiration;
 
+  /**
+   * Which HTTP status should we return?
+   */
+  unsigned int http_status;
+
+  /**
+   * Which error code should we return?
+   */
+  enum TALER_ErrorCode ec;
+
   /**
    * Are we suspended?
    */
@@ -175,14 +185,28 @@ handle_exchange (void *cls,
 
   rc->suspended = false;
   MHD_resume_connection (rc->connection);
+  if (NULL == hr)
+  {
+    rc->ec = TALER_EC_TIMEOUT;
+    rc->http_status = MHD_HTTP_REQUEST_TIMEOUT;
+    return;
+  }
   keys = TALER_EXCHANGE_get_keys (eh);
-  if ( (NULL != keys) &&
-       (NULL != payto_uri) )
+  if (NULL == keys)
+  {
+    rc->ec = TALER_EC_KEYS_INVALID;
+    rc->http_status = MHD_HTTP_FAILED_DEPENDENCY;
+    return;
+  }
+  if (NULL == payto_uri)
   {
-    rc->reserve_expiration
-      = GNUNET_TIME_relative_to_absolute (keys->reserve_closing_delay);
-    rc->payto_uri = GNUNET_strdup (payto_uri);
+    rc->ec = TALER_EC_RESERVES_POST_UNSUPPORTED_WIRE_METHOD;
+    rc->http_status = MHD_HTTP_CONFLICT;
+    return;
   }
+  rc->reserve_expiration
+    = GNUNET_TIME_relative_to_absolute (keys->reserve_closing_delay);
+  rc->payto_uri = GNUNET_strdup (payto_uri);
 }
 
 
@@ -249,8 +273,8 @@ TMH_private_post_reserves (const struct TMH_RequestHandler 
*rh,
   if (NULL == rc->payto_uri)
   {
     return TALER_MHD_reply_with_error (connection,
-                                       MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       
TALER_EC_RESERVES_POST_UNSUPPORTED_WIRE_METHOD,
+                                       rc->http_status,
+                                       rc->ec,
                                        "Exchange does not support wire 
method");
   }
   {

-- 
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]