Blame SOURCES/0156-ureport-improve-curl-s-error-messages.patch

28bab8
From b3d0e0225d155744f5aece391db31644dd7bd83a Mon Sep 17 00:00:00 2001
28bab8
From: Matej Habrnal <mhabrnal@redhat.com>
28bab8
Date: Wed, 16 Sep 2015 14:44:31 +0200
28bab8
Subject: [PATCH] ureport: improve curl's error messages
28bab8
28bab8
There were cases the 'post_state->errmsg' was empty and error message looks
28bab8
like "Failed to upload uReport to the server 'https://localhost:12345/faf' with
28bab8
curl:". This is kind of confusing because there is no information related to
28bab8
curl error part.  In the case the 'post_state->errmsg' is empty, error message
28bab8
without "with curl:" part will be printed. Also print information stored in
28bab8
'post_state->curl_error_msg', if is not empty.
28bab8
28bab8
Now, in the case the 'post_state->errmsg' is empty, the error message may look
28bab8
like this:
28bab8
Failed to upload uReport to the server 'https://localhost:12345/faf'
28bab8
Error: curl_easy_perform: Problem with the SSL CA cert (path? access rights?)
28bab8
28bab8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
28bab8
---
28bab8
 src/lib/ureport.c | 11 ++++++++++-
28bab8
 1 file changed, 10 insertions(+), 1 deletion(-)
28bab8
28bab8
diff --git a/src/lib/ureport.c b/src/lib/ureport.c
28bab8
index 76bcc95..ebeaa8b 100644
28bab8
--- a/src/lib/ureport.c
28bab8
+++ b/src/lib/ureport.c
28bab8
@@ -566,7 +566,16 @@ ureport_server_response_from_reply(post_state_t *post_state,
28bab8
      */
28bab8
     if (post_state->curl_result != CURLE_OK)
28bab8
     {
28bab8
-        error_msg(_("Failed to upload uReport to the server '%s' with curl: %s"), config->ur_url, post_state->errmsg);
28bab8
+        if (post_state->errmsg != NULL && strcmp( post_state->errmsg, "") != 0)
28bab8
+            error_msg(_("Failed to upload uReport to the server '%s' with curl: %s"),
28bab8
+                                                                    config->ur_url,
28bab8
+                                                                    post_state->errmsg);
28bab8
+        else
28bab8
+            error_msg(_("Failed to upload uReport to the server '%s'"), config->ur_url);
28bab8
+
28bab8
+        if (post_state->curl_error_msg != NULL && strcmp(post_state->curl_error_msg, "") != 0)
28bab8
+            error_msg(_("Error: %s"), post_state->curl_error_msg);
28bab8
+
28bab8
         return NULL;
28bab8
     }
28bab8
 
28bab8
-- 
28bab8
2.4.3
28bab8