From 237078adc0e47f4255f905ac3d84255e789ad52b Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Thu, 31 Mar 2022 11:10:40 +0000 Subject: [PATCH] Check curl error to string FossilOrigin-Name: 0903e3561f02cf9f2730313cce10a65f91095cec93915a790b6253c166960d18 --- src/fetch.c | 2 +- src/request.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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; }