Skip to content
Snippets Groups Projects
Verified Commit d6c8382f authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Handle CURLMcode without macro

parent 819e5bc6
No related branches found
No related tags found
No related merge requests found
......@@ -9,34 +9,25 @@ namespace coeurl {
std::shared_ptr<spdlog::logger> Client::log =
spdlog::null_logger_mt("coeurl_null");
#define mycase(code) \
case code: \
s = __STRING(code)
/* Die if we get a bad CURLMcode somewhere */
void Client::mcode_or_die(const char *where, CURLMcode code) {
if (CURLM_OK != code) {
const char *s;
const char *s = curl_multi_strerror(code);
switch (code) {
mycase(CURLM_BAD_HANDLE);
break;
mycase(CURLM_BAD_EASY_HANDLE);
break;
mycase(CURLM_OUT_OF_MEMORY);
break;
mycase(CURLM_INTERNAL_ERROR);
break;
mycase(CURLM_UNKNOWN_OPTION);
break;
mycase(CURLM_LAST);
case CURLM_BAD_SOCKET:
Client::log->error("{} returns {}", where, s);
/* ignore this error */
return;
case CURLM_BAD_HANDLE:
case CURLM_BAD_EASY_HANDLE:
case CURLM_OUT_OF_MEMORY:
case CURLM_INTERNAL_ERROR:
case CURLM_UNKNOWN_OPTION:
case CURLM_LAST:
break;
default:
s = "CURLM_unknown";
break;
mycase(CURLM_BAD_SOCKET);
Client::log->error("{} returns {}", where, s);
/* ignore this error */
return;
}
Client::log->critical("{} returns {}", where, s);
throw std::runtime_error(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment