From 5abfb9ab5749676bc41e9babe3f734dc6e9a12be Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 30 Mar 2010 14:15:07 +0200 Subject: trivial: better HTTP/curl error reporting Signed-off-by: Denys Vlasenko --- lib/Utils/abrt_curl.cpp | 4 ++++ lib/Utils/abrt_rh_support.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Utils/abrt_curl.cpp b/lib/Utils/abrt_curl.cpp index 6dc8582f..edc27124 100644 --- a/lib/Utils/abrt_curl.cpp +++ b/lib/Utils/abrt_curl.cpp @@ -135,8 +135,12 @@ curl_post(curl_post_state_t* state, const char* url, const char* data) curl_err = curl_easy_perform(handle); if (curl_err) { + VERB2 log("curl_easy_perform: error %d", (int)curl_err); if (state->flags & ABRT_CURL_POST_WANT_ERROR_MSG) + { state->curl_error_msg = check_curl_error(curl_err, "curl_easy_perform"); + VERB3 log("curl_easy_perform: error_msg: %s", state->curl_error_msg); + } goto ret; } diff --git a/lib/Utils/abrt_rh_support.cpp b/lib/Utils/abrt_rh_support.cpp index ff8ce48b..be2d3961 100644 --- a/lib/Utils/abrt_rh_support.cpp +++ b/lib/Utils/abrt_rh_support.cpp @@ -204,12 +204,21 @@ post_signature(const char* baseURL, const char* signature) strata_msg = find_header_in_curl_post_state(state, "Strata-Message:"); if (strata_msg) { - retval = xasprintf("Error (HTTP response %d): %s", + retval = xasprintf("Error (HTTP response %d): %s", http_resp_code, strata_msg); - break; + break; + } + if (state->curl_error_msg) + { + if (http_resp_code >= 0) + retval = xasprintf("Error (HTTP response %d): %s", http_resp_code, state->curl_error_msg); + else + retval = xasprintf("Error in HTTP transaction: %s", state->curl_error_msg); + break; } retval = xasprintf("Error (HTTP response %d), body:\n%s", http_resp_code, state->body); + break; } free_curl_post_state(state); -- cgit