Implement error checking. Thanks Pk11!

This commit is contained in:
VoltZ
2019-11-02 04:54:36 +01:00
committed by GitHub
parent eb88282782
commit 0b5bcc0d3c
+42 -22
View File
@@ -90,34 +90,54 @@ void runFunctions(void) {
std::string type = json.at(choice).at(i).at("type"); std::string type = json.at(choice).at(i).at("type");
if(type == "deleteFile") { if(type == "deleteFile") {
std::string file = json.at(choice).at(i).at("file"); bool missing = false;
std::string message = json.at(choice).at(i).at("message"); std::string file, message;
download::deleteFileList(file, message); if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
else missing = true;
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
if(!missing) download::deleteFileList(file, message);
} else if(type == "downloadFile") { } else if(type == "downloadFile") {
std::string file = json.at(choice).at(i).at("file"); bool missing = false;
std::string output = json.at(choice).at(i).at("output"); std::string file, output, message;
std::string message = json.at(choice).at(i).at("message"); if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
download::downloadFile(file, output, message); else missing = true;
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
else missing = true;
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
if(!missing) download::downloadFile(file, output, message);
} else if(type == "downloadRelease") { } else if(type == "downloadRelease") {
std::string repo = json.at(choice).at(i).at("repo"); bool missing = false;
std::string file = json.at(choice).at(i).at("file"); std::string repo, file, output, message;
std::string output = json.at(choice).at(i).at("output"); if(json.at(choice).at(i).contains("repo")) repo = json.at(choice).at(i).at("repo");
std::string message = json.at(choice).at(i).at("message"); else missing = true;
download::downloadRelease(repo, file, output, message); if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
else missing = true;
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
else missing = true;
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
if(!missing) download::downloadRelease(repo, file, output, message);
} else if(type == "extractFile") { } else if(type == "extractFile") {
std::string file = json.at(choice).at(i).at("file"); bool missing = false;
std::string input = json.at(choice).at(i).at("input"); std::string file, input, output, message;
std::string output = json.at(choice).at(i).at("output"); if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
std::string message = json.at(choice).at(i).at("message"); else missing = true;
download::extractFileList(file, input, output, message); if(json.at(choice).at(i).contains("input")) file = json.at(choice).at(i).at("input");
else missing = true;
if(json.at(choice).at(i).contains("output")) output = json.at(choice).at(i).at("output");
else missing = true;
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
if(!missing) download::extractFileList(file, input, output, message);
} else if(type == "installCia") { } else if(type == "installCia") {
std::string file = json.at(choice).at(i).at("file"); bool missing = false;
std::string message = json.at(choice).at(i).at("message"); std::string file, message;
download::installFileList(file, message); if(json.at(choice).at(i).contains("file")) file = json.at(choice).at(i).at("file");
else missing = true;
if(json.at(choice).at(i).contains("message")) message = json.at(choice).at(i).at("message");
if(!missing) download::installFileList(file, message);
} }
} }
doneMsg(); doneMsg();