From 080123ff96444fc0382cde6115b5c685a040f317 Mon Sep 17 00:00:00 2001 From: Martin Chang Date: Mon, 13 Dec 2021 12:37:31 +0800 Subject: [PATCH] use operator<< to convert ReqResult to string (#1126) --- lib/inc/drogon/HttpClient.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/inc/drogon/HttpClient.h b/lib/inc/drogon/HttpClient.h index 5835039e..248dcd3c 100644 --- a/lib/inc/drogon/HttpClient.h +++ b/lib/inc/drogon/HttpClient.h @@ -341,17 +341,10 @@ inline void internal::HttpRespAwaiter::await_suspend( setValue(resp); else { - std::string reason; - if (result == ReqResult::BadResponse) - reason = "BadResponse"; - else if (result == ReqResult::NetworkFailure) - reason = "NetworkFailure"; - else if (result == ReqResult::BadServerAddress) - reason = "BadServerAddress"; - else if (result == ReqResult::Timeout) - reason = "Timeout"; + std::stringstream ss; + ss << result; setException( - std::make_exception_ptr(std::runtime_error(reason))); + std::make_exception_ptr(std::runtime_error(ss.str()))); } handle.resume(); },