Added basic error handling for the cURL calls
All checks were successful
/ test (push) Successful in 19m10s

This commit is contained in:
Nick Martin 2025-05-26 13:08:15 -04:00
parent 9d938f8bc2
commit a4c4dbc227

View file

@ -23,7 +23,7 @@ CURL *curl;
CURLcode res; CURLcode res;
std::string old_response = "Dummy"; std::string old_response = "Dummy";
std::string walltaker_id = ""; std::string walltaker_id = "";
NOTIFYICONDATAA nid;
int imgconvert(std::string filepath){ int imgconvert(std::string filepath){
int width; int width;
@ -92,6 +92,11 @@ int UpdateWallpaper(){
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, getAnswerFunction); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, getAnswerFunction);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_string); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_string);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != 0){
// Connection failed for some reason, exit fuction
printf("Error connecting to API, retrying in 10 seconds...\n");
return 0;
}
//std::cout << response_string << "\n"; //std::cout << response_string << "\n";
// Who needs parsing when you have regex? // Who needs parsing when you have regex?
@ -115,7 +120,11 @@ int UpdateWallpaper(){
img = fopen(fname.c_str(), "wb"); img = fopen(fname.c_str(), "wb");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, img); curl_easy_setopt(curl, CURLOPT_WRITEDATA, img);
//curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != 0){
printf("Error connecting to e621, retrying in 10 seconds...\n");
return 0;
}
old_response = esixurl; old_response = esixurl;
fclose(img); fclose(img);
@ -165,11 +174,12 @@ int main (int argc, char *argv[]) {
LoadConfig(); LoadConfig();
HWND hwnd = CreateWindowW(L"static", L"Dummy Window", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); HWND hwnd = CreateWindowW(L"static", L"Dummy Window", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
printf("Starting Walltaker95, please wait...\n"); //printf("Starting Walltaker95, please wait...\n");
NOTIFYICONDATAA nid;
nid.hWnd = hwnd; // handle to the window that will display the tray icon nid.hWnd = hwnd; // handle to the window that will display the tray icon
nid.cbSize = NOTIFYICONDATA_V2_SIZE;
nid.uID = 100; // unique identifier for the tray icon nid.uID = 100; // unique identifier for the tray icon
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; // flags to indicate which fields are valid nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP | NIF_INFO; // flags to indicate which fields are valid
nid.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); nid.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
nid.uVersion = 0; nid.uVersion = 0;
nid.uCallbackMessage = APPWM_ICONNOTIFY; nid.uCallbackMessage = APPWM_ICONNOTIFY;