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

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