cURL / Mailing Lists / curl-library / Single Mail


Re: CURLcode_strerror

From: codemastr <>
Date: Sun, 29 Feb 2004 17:50:10 -0500

> Why is a strerror() equivalent better than simply using the
> CURLOPT_ERRORBUFFER option? The latter is even more than simply a
> of the error code, it can also provide additional info from the particular
> situaion that caused the problem this time.

Indeed, but CURLOPT_ERRORBUFFER only deals with curl_easy_perform. Many
other curl functions return error codes. Let me provide a hypothetical
scenario. I'm a C++ programmer and I'm making an exception based interface
to libcurl. So I have Curl::Easy::SetOpt. Someone decides to pass an illegal
value into this function as the option. This prompts the underlying
curl_easy_setopt to return CURLE_FAILED_INIT. Now, I want to throw an
exception when this happens. One of the functions of a C++ exception is the
what() function. This function displays a text string describing the
particular exception. Now if Curl had a strerror I would do:

char *what() { return curl_easy_strerror(CURLE_FAILED_INIT); }

However, since libcurl does not have this, I would have to manually include
my own string equivilent.

Certainly, CURLOPT_ERRORBUFFER is much better at reporting errors since, as
you said, it includes additional information. But, that option only applies
to curl_easy_perform.

Dominick Meglio
Received on 2004-02-29