error checking
This commit is contained in:
parent
de997ea693
commit
75a86a9df5
|
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.7)
|
|||
include(GNUInstallDirs)
|
||||
|
||||
project (soupbot
|
||||
VERSION 0.2.2
|
||||
VERSION 0.2.3
|
||||
LANGUAGES CXX
|
||||
)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
|
||||
|
|
|
@ -45,6 +45,7 @@ You will need a pre-generated authentication code.
|
|||
| 16 | Connection failed |
|
||||
| 17 | TLS error |
|
||||
| 18 | Invalid response from server |
|
||||
| 32 | File not readable |
|
||||
| 100 - 999 | HTTP status codes |
|
||||
| 65535 | Unknown exception |
|
||||
|
||||
|
|
|
@ -100,17 +100,26 @@ int main(int argc, char *argv[])
|
|||
pt::ptree config;
|
||||
string instance = "";
|
||||
string access_token = "";
|
||||
|
||||
read_config(config, instance, access_token);
|
||||
|
||||
pt::ptree ingredients;
|
||||
pt::read_json(filepath + "ingredients.json", ingredients);
|
||||
std::vector<string> vegetables;
|
||||
std::vector<string> spices;
|
||||
std::vector<string> fruits;
|
||||
std::vector<string> misc;
|
||||
std::vector<string> highprio;
|
||||
|
||||
read_config(config, instance, access_token);
|
||||
|
||||
try
|
||||
{
|
||||
pt::read_json(filepath + "ingredients.json", ingredients);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
// most likely file not found
|
||||
std::cerr << "ERROR: " << filepath << "ingredients.json not found or not readable.\n";
|
||||
return 32;
|
||||
}
|
||||
|
||||
populate_vector(ingredients, "vegetables", vegetables);
|
||||
populate_vector(ingredients, "spices", spices);
|
||||
populate_vector(ingredients, "fruits", fruits);
|
||||
|
|
Loading…
Reference in New Issue