diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-05 22:17:55 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-05 22:17:55 +0200 |
commit | 4350dd058ec43f1a8d6478b774209475bc4f4654 (patch) | |
tree | 319339a7e6e982df1e012405ed7b8eade75c4ce1 /src/core | |
parent | 2b7b8cb36539c73847e8ab05d5bc02eed9821815 (diff) | |
download | weechat-4350dd058ec43f1a8d6478b774209475bc4f4654.zip |
core: display curl error after a failed download
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-hook.c | 2 | ||||
-rw-r--r-- | src/core/wee-url.c | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 5a12ec8f2..a72324833 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -1528,8 +1528,6 @@ hook_process_child (struct t_hook *hook_process) ptr_url++; } rc = weeurl_download (ptr_url, HOOK_PROCESS(hook_process, options)); - if (rc != 0) - fprintf (stderr, "Error with URL '%s'\n", ptr_url); } else { diff --git a/src/core/wee-url.c b/src/core/wee-url.c index 8b75ec43c..88df5a105 100644 --- a/src/core/wee-url.c +++ b/src/core/wee-url.c @@ -885,6 +885,8 @@ struct t_url_option url_options[] = { NULL, 0, 0, NULL }, }; +char url_error[CURL_ERROR_SIZE + 1]; + /* * Searches for a constant in array of constants. @@ -1160,7 +1162,7 @@ weeurl_download (const char *url, struct t_hashtable *options) CURLoption url_file_opt_data[2] = { CURLOPT_READDATA, CURLOPT_WRITEDATA }; void *url_file_opt_cb[2] = { &weeurl_read, &weeurl_write }; struct t_proxy *ptr_proxy; - int rc, i; + int rc, curl_rc, i; rc = 0; @@ -1219,9 +1221,18 @@ weeurl_download (const char *url, struct t_hashtable *options) /* set other options in hashtable */ hashtable_map (options, &weeurl_option_map_cb, curl); + /* set error buffer */ + curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, url_error); + /* perform action! */ - if (curl_easy_perform (curl) != CURLE_OK) + curl_rc = curl_easy_perform (curl); + if (curl_rc != CURLE_OK) + { + fprintf (stderr, + _("curl error %d (%s) (URL: \"%s\")\n"), + curl_rc, url_error, url); rc = 2; + } /* cleanup */ curl_easy_cleanup (curl); |