lib/curl/Easy: add method TrySetOption()

This commit is contained in:
Max Kellermann 2024-01-04 17:50:41 +01:00
parent cbd031ca7f
commit 997311ba14

View File

@ -63,9 +63,14 @@ public:
return handle; return handle;
} }
template<typename T>
CURLcode TrySetOption(CURLoption option, T value) noexcept {
return curl_easy_setopt(handle, option, value);
}
template<typename T> template<typename T>
void SetOption(CURLoption option, T value) { void SetOption(CURLoption option, T value) {
CURLcode code = curl_easy_setopt(handle, option, value); CURLcode code = TrySetOption(option, value);
if (code != CURLE_OK) if (code != CURLE_OK)
throw Curl::MakeError(code, "Failed to set option"); throw Curl::MakeError(code, "Failed to set option");
} }