forgot try catch statement

This commit is contained in:
Luna 2024-10-06 20:55:16 +03:00
parent 0509d16de9
commit 89c280a785
2 changed files with 23 additions and 9 deletions

View file

@ -33,7 +33,10 @@ void getHttp(std::string url, std::string *outputfile){
curl_easy_setopt(meow, CURLOPT_WRITEFUNCTION, appendCurlOutputToString); curl_easy_setopt(meow, CURLOPT_WRITEFUNCTION, appendCurlOutputToString);
curl_easy_setopt(meow, CURLOPT_WRITEDATA, &woof); curl_easy_setopt(meow, CURLOPT_WRITEDATA, &woof);
// perform the request // perform the request
curl_easy_perform(meow); res = curl_easy_perform(meow);
if (res != CURLE_OK){
throw("failed to perform the request\n");
}
writeHtmlFile(&woof, outputfile); writeHtmlFile(&woof, outputfile);
curl_easy_cleanup(meow); curl_easy_cleanup(meow);
} }

View file

@ -85,8 +85,13 @@ int main(int argc, char **argv, char **envp) {
if (argc == 7) { if (argc == 7) {
dir = ARGS[1+5]; dir = ARGS[1+5];
} }
try {
getHttp(std::string {"https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid}, &cachesc); getHttp(std::string {"https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid}, &cachesc);
}
catch(std::string& meow) {
std::cout << meow;
return 1;
}
std::cout << collectionid << user << pass << gameid << dir; std::cout << collectionid << user << pass << gameid << dir;
std::cout << "success1\n"; std::cout << "success1\n";
break; break;
@ -100,9 +105,15 @@ int main(int argc, char **argv, char **envp) {
if (argc == 5) { if (argc == 5) {
dir = ARGS[1+3]; dir = ARGS[1+3];
} }
try {
getHttp(std::string {"https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid}, &cachesc); getHttp(std::string {"https://steamcommunity.com/sharedfiles/filedetails/?id=" + collectionid}, &cachesc);
std::cout << collectionid << gameid << dir; }
catch(std::string& meow) {
std::cout << meow;
return 1;
}
std::cout << collectionid << gameid << dir << '\n';
std::cout << "success\n"; std::cout << "success\n";
break; break;