From a3dbbcfd2ac7ab8f597e26e76935726279d3fa0c Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Wed, 4 Jul 2012 17:03:52 +0200 Subject: Added error checking for samples. --- docs/examples/fileupload.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'docs/examples/fileupload.c') diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c index 756367b6b..665eca0af 100644 --- a/docs/examples/fileupload.c +++ b/docs/examples/fileupload.c @@ -64,14 +64,21 @@ int main(void) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) { + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); - /* now extract transfer info */ - curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload); - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); + } + else { + /* now extract transfer info */ + curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &speed_upload); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); - fprintf(stderr, "Speed: %.3f bytes/sec during %.3f seconds\n", - speed_upload, total_time); + fprintf(stderr, "Speed: %.3f bytes/sec during %.3f seconds\n", + speed_upload, total_time); + } /* always cleanup */ curl_easy_cleanup(curl); } -- cgit v1.2.3