Added exceptions

dev v0.1_beta
marcelb 2 years ago
parent e4bde2e783
commit 1a84ca7109
  1. 3
      .vscode/settings.json
  2. 8
      src/config.cpp

@ -2,6 +2,7 @@
"files.associations": { "files.associations": {
"*.tcc": "cpp", "*.tcc": "cpp",
"compare": "cpp", "compare": "cpp",
"type_traits": "cpp" "type_traits": "cpp",
"iostream": "cpp"
} }
} }

@ -4,12 +4,10 @@
config::config(const string _configFilePath, const vector<string> _necessary) { config::config(const string _configFilePath, const vector<string> _necessary) {
necessary = _necessary; necessary = _necessary;
if(!init(_configFilePath)) { if(!init(_configFilePath)) {
cout << "ERROR init config file" << endl; throw "[ERROR] Init config file ";
exit(1);
} }
if (!isHaveNecessary()) { if (!isHaveNecessary()) {
cout << "ERROR Konfiguracijska datoteka nema sva nužna polja!" << endl; throw "[ERROR] Configuration file does not have all the required fields ";
exit(2);
} }
} }
@ -23,7 +21,7 @@ bool config::init(const string _configFilePath) {
ifstream configFile; ifstream configFile;
configFile.open(_configFilePath, ios::in); configFile.open(_configFilePath, ios::in);
if(!configFile) { if(!configFile) {
printf ("[CRITICAL ERROR] Nema konfiguracijske datoteke!"); //printf ("[CRITICAL ERROR] Nema konfiguracijske datoteke!");
return false; return false;
} }

Loading…
Cancel
Save