diff --git a/src/fetch.c b/src/fetch.c index fcf1f6f..b689299 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -49,7 +49,7 @@ int mastodont_fetch_curl(mastodont_t* mstdnt, struct mstdnt_fetch_results* results, CURLoption request_t) { - int res; + int res = 3; char token[TOKEN_STR_SIZE] = { 0 }; struct curl_slist* list = NULL; diff --git a/src/request.c b/src/request.c index 40ba943..0c6a3a5 100644 --- a/src/request.c +++ b/src/request.c @@ -21,7 +21,7 @@ int mastodont_request(mastodont_t* data, struct mastodont_request_args* args) { - int res = 0; + int res = 0, curlerror = 0; struct mstdnt_storage* storage = args->storage; struct mstdnt_fetch_results results = { 0 }; char* post; @@ -39,9 +39,11 @@ int mastodont_request(mastodont_t* data, struct mastodont_request_args* args) curl_easy_setopt(data->curl, CURLOPT_POSTFIELDS, post); } - if (mastodont_fetch_curl(data, url_query, &results, args->request_type) != CURLE_OK) + curlerror = mastodont_fetch_curl(data, url_query, &results, args->request_type); + if (curlerror != CURLE_OK) { res = 1; + storage->error = (char*)curl_easy_strerror(curlerror); goto cleanup; }