From e79e61737bc1d19d2305372710d64b967520c1d6 Mon Sep 17 00:00:00 2001 From: Jinming Hu Date: Tue, 11 Feb 2020 17:52:20 +0800 Subject: [PATCH] Fix issue: storage_error didn't contain any error information when curl failed --- include/executor.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/executor.h b/include/executor.h index 357c070..b877b36 100644 --- a/include/executor.h +++ b/include/executor.h @@ -76,8 +76,18 @@ namespace azure { namespace storage_lite { std::string str(std::istreambuf_iterator(s.istream()), std::istreambuf_iterator()); if (code != CURLE_OK || unsuccessful(result)) { - auto error = context->xml_parser()->parse_storage_error(str); - error.code = std::to_string(result); + storage_error error; + if (code != CURLE_OK) + { + error.code = std::to_string(code); + error.code_name = curl_easy_strerror(code); + } + else + { + error = context->xml_parser()->parse_storage_error(str); + error.code = std::to_string(result); + } + *outcome = storage_outcome(error); retry->add_result(code == CURLE_OK ? result: 503); http->reset_input_stream(); @@ -138,11 +148,21 @@ namespace azure { namespace storage_lite { { http->submit([promise, outcome, account, request, http, context, retry](http_base::http_code result, storage_istream s, CURLcode code) { - std::string str(std::istreambuf_iterator(s.istream()), std::istreambuf_iterator()); if (code != CURLE_OK || unsuccessful(result)) { - auto error = context->xml_parser()->parse_storage_error(str); - error.code = std::to_string(result); + storage_error error; + if (code != CURLE_OK) + { + error.code = std::to_string(code); + error.code_name = curl_easy_strerror(code); + } + else + { + std::string str(std::istreambuf_iterator(s.istream()), std::istreambuf_iterator()); + error = context->xml_parser()->parse_storage_error(str); + error.code = std::to_string(result); + } + *outcome = storage_outcome(error); retry->add_result(code == CURLE_OK ? result: 503); http->reset_input_stream();