gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated: nicely handle error


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: nicely handle error from json_dumps without assert
Date: Tue, 09 May 2017 13:24:09 +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 6da3f7f  nicely handle error from json_dumps without assert
6da3f7f is described below

commit 6da3f7ff89e8d2a1f2cdd829632aab9cf69bd0e4
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue May 9 13:29:23 2017 +0200

    nicely handle error from json_dumps without assert
---
 src/include/taler_merchant_service.h | 14 +++++++-------
 src/lib/merchant_api_proposal.c      | 17 +++++++++++------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 7b8fa28..132a4c9 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -50,7 +50,7 @@ struct TALER_MERCHANT_ProposalLookupOperation;
  * @param cls closure
  * @param http_status HTTP response code, 200 indicates success;
  *                    0 if the backend's reply is bogus (fails to follow the 
protocol)
- * @param ec taler-specific error code 
+ * @param ec taler-specific error code
  * @param obj raw JSON reply, or error details if the request failed
  * @param proposal_data completed contract, NULL on error
  * @param sig merchant's signature over the contract, NULL on error
@@ -88,7 +88,7 @@ typedef void
  * backend
  * @param proposal_cb the callback to call when a reply for this request is 
available
  * @param proposal_cb_cls closure for @a proposal_cb
- * @return a handle for this request
+ * @return a handle for this request, NULL on error
  */
 struct TALER_MERCHANT_ProposalOperation *
 TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
@@ -162,7 +162,7 @@ struct TALER_MERCHANT_Pay;
  *                    can indicate success, depending on whether the 
interaction
  *                    was with a merchant frontend or backend;
  *                    0 if the merchant's reply is bogus (fails to follow the 
protocol)
- * @param ec taler-specific error code 
+ * @param ec taler-specific error code
  * @param obj the received JSON reply, with error details if the request failed
  */
 typedef void
@@ -364,7 +364,7 @@ struct TALER_MERCHANT_TrackTransferHandle;
  * transfer.
  */
 struct TALER_MERCHANT_TrackTransferDetails {
-  
+
   /**
    * Total amount paid back by the exchange.
    */
@@ -387,7 +387,7 @@ struct TALER_MERCHANT_TrackTransferDetails {
  *
  * @param cls closure
  * @param http_status HTTP status code we got, 0 on exchange protocol violation
- * @param ec taler-specific error code 
+ * @param ec taler-specific error code
  * @param sign_key exchange key used to sign @a json, or NULL
  * @param json original json reply (may include signatures, those have then 
been
  *        validated already)
@@ -508,7 +508,7 @@ struct TALER_MERCHANT_TransactionWireTransfer
  *
  * @param cls closure
  * @param http_status HTTP status code we got, 0 on exchange protocol violation
- * @param ec taler-specific error code 
+ * @param ec taler-specific error code
  * @param json original json reply from the backend
  * @param num_transfers number of wire transfers the exchange used for the 
transaction
  * @param transfers details about each transfer and which coins are aggregated 
in it
@@ -560,7 +560,7 @@ struct TALER_MERCHANT_HistoryOperation;
  *
  * @param cls closure
  * @param http_status HTTP status returned by the merchant backend
- * @param ec taler-specific error code 
+ * @param ec taler-specific error code
  * @param json actual body containing history
  */
 typedef void
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index c3e5873..5a05c26 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -137,7 +137,7 @@ handle_proposal_finished (void *cls,
         GNUNET_JSON_spec_fixed_auto ("hash", &hash),
         GNUNET_JSON_spec_end()
       };
-  
+
       if (GNUNET_OK !=
           GNUNET_JSON_parse (json,
                              spec,
@@ -200,7 +200,7 @@ handle_proposal_finished (void *cls,
  * @param proposal_cb the callback to call when a reply for this request is
  * available
  * @param proposal_cb_cls closure for @a proposal_cb
- * @return a handle for this request
+ * @return a handle for this request, NULL on error
  */
 struct TALER_MERCHANT_ProposalOperation *
 TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
@@ -225,10 +225,15 @@ TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
   req = json_pack ("{s:O}",
                    "order", (json_t *) order);
   eh = curl_easy_init ();
-  GNUNET_assert (NULL != (po->json_enc =
-                          json_dumps (req,
-                                      JSON_COMPACT)));
+  po->json_enc = json_dumps (req,
+                             JSON_COMPACT);
   json_decref (req);
+  if (NULL == po->json_enc)
+  {
+    GNUNET_break (0);
+    GNUNET_free (po);
+    return NULL;
+  }
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_URL,
@@ -310,7 +315,7 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context 
*ctx,
                                     CURLOPT_URL,
                                     plo->url))
   {
-    GNUNET_break (0);  
+    GNUNET_break (0);
     return NULL;
   }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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