CURLcode return codes
Many libcurl functions return a CURLcode. That is a special libcurl typedefedvariable for error codes. It returnsCURLE_OK
(which has the value zero) ifeverything is fine and dandy and it returns a non-zero number if a problem wasdetected. There are almost one hundredCURLcode
errors in use, and you canfind them all in thecurl/curl.h
header file and documented in thelibcurl-errors man page.
You can convert a CURLcode into a human readable string with thecurl_easy_strerror()
function—but be aware that these errors are rarelyphrased in a way that is suitable for anyone to expose in a UI or to an enduser:
const char *str = curl_easy_strerror( error );printf("libcurl said %s\n", str);
Another way to get a slightly better error text in case of errors is to settheCURLOPT_ERRORBUFFER
option to point out a buffer in your program andthen libcurl stores a related error message there before it returns an error:
char error[CURL_ERROR_SIZE]; /* needs to be at least this big */CURLcode ret = curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, error);