summaryrefslogtreecommitdiff
path: root/docs/libcurl/opts/CURLOPT_ERRORBUFFER.html
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2015-08-12 10:34:59 +0200
committerAlessandro Ghedini <alessandro@ghedini.me>2015-08-12 10:34:59 +0200
commit9456f51adb76b83ceb4b95c8481325de62b25ad2 (patch)
treee5cfc1f4bc28cd81e93a96f9707a0efb143d278a /docs/libcurl/opts/CURLOPT_ERRORBUFFER.html
parentdbada9f3efae6d9d47b24d0fc06b31d5c48e59a9 (diff)
Imported Upstream version 7.44.0
Diffstat (limited to 'docs/libcurl/opts/CURLOPT_ERRORBUFFER.html')
-rw-r--r--docs/libcurl/opts/CURLOPT_ERRORBUFFER.html26
1 files changed, 22 insertions, 4 deletions
diff --git a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.html b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.html
index 7d45d29f..519891a7 100644
--- a/docs/libcurl/opts/CURLOPT_ERRORBUFFER.html
+++ b/docs/libcurl/opts/CURLOPT_ERRORBUFFER.html
@@ -63,15 +63,33 @@ p.roffit {
<p class="level0"><pre class="level0">
curl = curl_easy_init();
if(curl) {
-&nbsp; char error[CURL_ERROR_SIZE]
+&nbsp; CURLcode res;
+&nbsp; char errbuf[CURL_ERROR_SIZE];
&nbsp;
&nbsp; curl_easy_setopt(curl, CURLOPT_URL, "<a href="http://example.com">http://example.com</a>");
&nbsp;
&nbsp; /* provide a buffer to store errors in */
-&nbsp; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error);
+&nbsp; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
&nbsp;
-&nbsp; /* Perform the request */
-&nbsp; curl_easy_perform(curl);
+&nbsp; /* set the error buffer as empty before performing a request */
+&nbsp; errbuf[0] = 0;
+&nbsp;
+&nbsp; /* perform the request */
+&nbsp; res = curl_easy_perform(curl);
+&nbsp;
+&nbsp; /* if the request did not complete correctly, show the error
+&nbsp; information. if no detailed error information was written to errbuf
+&nbsp; show the more generic information from curl_easy_strerror instead.
+&nbsp; */
+&nbsp; if(res != CURLE_OK) {
+&nbsp; size_t len = strlen(errbuf);
+&nbsp; fprintf(stderr, "\nlibcurl: (%d) ", res);
+&nbsp; if(len)
+&nbsp; fprintf(stderr, "%s%s", errbuf,
+&nbsp; ((errbuf[len - 1] != '\n') ? "\n" : ""));
+&nbsp; else
+&nbsp; fprintf(stderr, "%s\n", curl_easy_strerror(res));
+&nbsp; }
}
</pre>