cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLcode_strerror

From: codemastr <codemstr_at_ptd.net>
Date: Sat, 28 Feb 2004 12:20:09 -0500

> I suspect the reason something like this hasn't already been added is the
> problem of i18n. At best, the error strings ought to be surrounded
> by N_(...) so they can be translated, and at worst, libcurl should have
> a dependency on libintl and carry with it a set of language files with
> translated messages. That's a lot of complication and overhead for a few
> short text strings, none of which a user will actually see in normal
> operation. On the other hand, it shouldn't have to be the responsibility
> of each application developer to keep his own set of error strings up
> to date with each libcurl release, and putting them into libcurl is the
> only way to accomplish that.
Yeah you're right. I do like the idea however, if nothing else it is useful
for debugging. Really though, some of these errors might be displayed to the
user (malformed URL, etc). But I have some suggestions on how to implement
this differently. CURLcode is not the only error code curl uses, you have
CURLMcode (which doesn't currently do much) and CURLSHcode as well. I think
the best way to implement this would be with 3 seperate functions:
const char *curl_easy_strerror(CURLcode code);
const char *curl_multi_strerror(CURLMcode code);
const char *curl_share_strerror(CURLSHcode code);

The curl_multi_strerror would not really be needed but it seems logical to
add in case more error codes are ever added for the multi interface. The
other issue, as mentioned, was i18n. Normally I'd agree, adding gettext()
support for something like strerror would be stupid and wasteful, but there
is another thing you forgot to mention. Curl itself could benefit from
gettext()! The curl program displays everything in English, if gettext()
were supported, it would mean not only could strerror be translated, but
curl itself could be as well. Plus, libcurl displays more errors than just
what would be displays there. I mean when you specify CURLOPT_ERRORBUFFER
you get English text. That text could benefit from i18n as well. So I think
this would be a good idea to add as well, though of course it should work
just fine without gettext() for things like MSVC.

Dominick Meglio
Received on 2004-02-28