summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hook/wee-hook-url.c27
-rw-r--r--src/core/wee-url.c7
2 files changed, 28 insertions, 6 deletions
diff --git a/src/core/hook/wee-hook-url.c b/src/core/hook/wee-hook-url.c
index 4c10d028b..f34d767a2 100644
--- a/src/core/hook/wee-hook-url.c
+++ b/src/core/hook/wee-hook-url.c
@@ -126,14 +126,22 @@ void *
hook_url_transfer_thread (void *hook_pointer)
{
struct t_hook *hook;
+ int url_rc;
+ char str_error_code[12];
hook = (struct t_hook *)hook_pointer;
pthread_cleanup_push (&hook_url_thread_cleanup, hook);
- (void) weeurl_download (HOOK_URL(hook, url),
- HOOK_URL(hook, options),
- HOOK_URL(hook, output));
+ url_rc = weeurl_download (HOOK_URL(hook, url),
+ HOOK_URL(hook, options),
+ HOOK_URL(hook, output));
+
+ if (url_rc != 0)
+ {
+ snprintf (str_error_code, sizeof (str_error_code), "%d", url_rc);
+ hashtable_set (HOOK_URL(hook, output), "error_code", str_error_code);
+ }
pthread_cleanup_pop (1);
@@ -149,7 +157,7 @@ hook_url_timer_cb (const void *pointer, void *data, int remaining_calls)
{
struct t_hook *hook;
const char *ptr_error;
- char str_error[1024];
+ char str_error[1024], str_error_code[12];
/* make C compiler happy */
(void) data;
@@ -179,12 +187,14 @@ hook_url_timer_cb (const void *pointer, void *data, int remaining_calls)
if (remaining_calls == 0)
{
- if (!hashtable_has_key (HOOK_URL(hook, output), "error"))
+ if (!hashtable_has_key (HOOK_URL(hook, output), "error_code"))
{
snprintf (str_error, sizeof (str_error),
"transfer timeout reached (%.3fs)",
((float)HOOK_URL(hook, timeout)) / 1000);
+ snprintf (str_error_code, sizeof (str_error_code), "6");
hashtable_set (HOOK_URL(hook, output), "error", str_error);
+ hashtable_set (HOOK_URL(hook, output), "error_code", str_error_code);
}
hook_url_run_callback (hook);
if (weechat_debug_core >= 1)
@@ -212,6 +222,7 @@ hook_url_transfer (struct t_hook *hook)
{
int rc, timeout, max_calls;
long interval;
+ char str_error[1024], str_error_code[12], str_error_code_pthread[12];
HOOK_URL(hook, thread_running) = 1;
@@ -222,7 +233,13 @@ hook_url_transfer (struct t_hook *hook)
{
snprintf (str_error, sizeof (str_error),
"error calling pthread_create (%d)", rc);
+ snprintf (str_error_code, sizeof (str_error_code), "5");
+ snprintf (str_error_code_pthread, sizeof (str_error_code_pthread),
+ "%d", rc);
hashtable_set (HOOK_URL(hook, output), "error", str_error);
+ hashtable_set (HOOK_URL(hook, output), "error_code", str_error_code);
+ hashtable_set (HOOK_URL(hook, output), "error_code_pthread",
+ str_error_code_pthread);
hook_url_run_callback (hook);
gui_chat_printf (NULL,
diff --git a/src/core/wee-url.c b/src/core/wee-url.c
index 7ec89b94f..8f77a048d 100644
--- a/src/core/wee-url.c
+++ b/src/core/wee-url.c
@@ -1344,7 +1344,8 @@ weeurl_download (const char *url, struct t_hashtable *options,
struct t_url_file url_file[2];
char *url_file_option[2] = { "file_in", "file_out" };
char *url_file_mode[2] = { "rb", "wb" };
- char url_error[CURL_ERROR_SIZE + 1], **string_headers, **string_output;
+ char url_error[CURL_ERROR_SIZE + 1], url_error_code[12];
+ char **string_headers, **string_output;
char str_response_code[32];
CURLoption url_file_opt_func[2] = { CURLOPT_READFUNCTION, CURLOPT_WRITEFUNCTION };
CURLoption url_file_opt_data[2] = { CURLOPT_READDATA, CURLOPT_WRITEDATA };
@@ -1358,6 +1359,7 @@ weeurl_download (const char *url, struct t_hashtable *options,
string_headers = NULL;
string_output = NULL;
url_error[0] = '\0';
+ url_error_code[0] = '\0';
for (i = 0; i < 2; i++)
{
@@ -1465,6 +1467,7 @@ weeurl_download (const char *url, struct t_hashtable *options,
{
if (output)
{
+ snprintf (url_error_code, sizeof (url_error_code), "%d", curl_rc);
if (!url_error[0])
{
snprintf (url_error, sizeof (url_error),
@@ -1507,6 +1510,8 @@ end:
}
if (url_error[0])
hashtable_set (output, "error", url_error);
+ if (url_error_code[0])
+ hashtable_set (output, "error_code_curl", url_error_code);
}
return rc;
}