curl_exception: add error() function and improve message handling

This commit is contained in:
Syping 2026-04-05 09:25:43 +02:00
parent 2282c2875c
commit 481a2a8357
3 changed files with 13 additions and 8 deletions

View file

@ -40,7 +40,7 @@ const http_response http_request::get(const std::string &url, const http_headers
curl_easy_getinfo(instance, CURLINFO_RESPONSE_CODE, &response.status);
curl_easy_reset(instance);
return result == CURLE_OK ?
response : throw bot::exception::curl_exception(strlen(error) ? error : curl_easy_strerror(result), result);
response : throw bot::exception::curl_exception(error, result);
}
const http_response http_request::post(const std::string &url, const std::string &content, const http_headers &headers) {
@ -58,7 +58,7 @@ const http_response http_request::post(const std::string &url, const std::string
curl_easy_getinfo(instance, CURLINFO_RESPONSE_CODE, &response.status);
curl_easy_reset(instance);
return result == CURLE_OK ?
response : throw bot::exception::curl_exception(strlen(error) ? error : curl_easy_strerror(result), result);
response : throw bot::exception::curl_exception(error, result);
}
std::string http_request::legacy_url(const std::string &hostname, uint16_t port, const std::string &url, bool tls) {