use eoExceptions everywhere

This commit is contained in:
Johann Dreo 2020-03-27 00:21:52 +01:00
commit eba2e14950
127 changed files with 524 additions and 418 deletions

View file

@ -111,8 +111,8 @@ public:
std::fstream file(_fileName.c_str(), std::ios::in);
if (!file) {
std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
throw std::runtime_error(str);
// std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ;
throw eoFileError(_fileName);
}
std::string s;
@ -128,12 +128,12 @@ public:
// parameters
if (s[0] != 'p') {
std::string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ;
throw std::runtime_error(str);
throw eoException(_fileName);
}
file >> s;
if (s != "cnf") {
std::string str = "MaxSATeval: " + _fileName + " is not a file in cnf format.";
throw std::runtime_error(str);
throw eoException(_fileName);
}
file >> nbVar >> nbClauses;
@ -187,7 +187,7 @@ public:
if (!file) {
std::string str = "MaxSATeval: Could not open " + _fileName;
throw std::runtime_error(str);
throw eoFileError(_fileName);
}
// write some commentaries

View file

@ -154,13 +154,13 @@ public:
// Read the parameters
if (s[0] != 'p') {
std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ;
throw std::runtime_error(str);
throw eoException(str);
}
file >> s;
if (s != "NK") {
std::string str = "nkLandscapesEval.load: -- NK -- expected in [" + _fileName + "] at the begining." ;
throw std::runtime_error(str);
throw eoException(str);
}
// read parameters N and K
@ -170,7 +170,7 @@ public:
// read the links
if (s[0] != 'p') {
std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N and K." ;
throw std::runtime_error(str);
throw eoException(str);
}
file >> s;
@ -178,13 +178,13 @@ public:
loadLinks(file);
} else {
std::string str = "nkLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N and K." ;
throw std::runtime_error(str);
throw eoException(str);
}
// lecture des tables
if (s[0] != 'p') {
std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ;
throw std::runtime_error(str);
throw eoException(str);
}
file >> s;
@ -193,13 +193,13 @@ public:
loadTables(file);
} else {
std::string str = "nkLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ;
throw std::runtime_error(str);
throw eoException(str);
}
file.close();
} else {
std::string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw std::runtime_error(str);
// std::string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw eoFileError(_fileName);
}
};

View file

@ -115,13 +115,13 @@ public:
// Read the parameters
if (s[0] != 'p') {
string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
if (s != "NKp") {
string str = "nkpLandscapesEval.load: -- NKp -- expected in [" + _fileName + "] at the begining." ;
throw runtime_error(str);
throw eoException(str);
}
// read parameters N, K and p
@ -131,7 +131,7 @@ public:
// read the links
if (s[0] != 'p') {
string str = "nkpLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N, K, and p." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
@ -139,13 +139,13 @@ public:
loadLinks(file);
} else {
string str = "nkpLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N, K, and q." ;
throw runtime_error(str);
throw eoException(str);
}
// lecture des tables
if (s[0] != 'p') {
string str = "nkpLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
@ -154,13 +154,13 @@ public:
loadTables(file);
} else {
string str = "nkpLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ;
throw runtime_error(str);
throw eoException(str);
}
file.close();
} else {
string str = "nkpLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw runtime_error(str);
// string str = "nkpLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw eoFileError(_fileName);
}
};

View file

@ -114,13 +114,13 @@ public:
// Read the parameters
if (s[0] != 'p') {
string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
if (s != "NKq") {
string str = "nkqLandscapesEval.load: -- NKq -- expected in [" + _fileName + "] at the begining." ;
throw runtime_error(str);
throw eoException(str);
}
// read parameters N, K and q
@ -130,7 +130,7 @@ public:
// read the links
if (s[0] != 'p') {
string str = "nkqLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N, K, and q." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
@ -138,13 +138,13 @@ public:
loadLinks(file);
} else {
string str = "nkqLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N, K, and q." ;
throw runtime_error(str);
throw eoException(str);
}
// lecture des tables
if (s[0] != 'p') {
string str = "nkqLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ;
throw runtime_error(str);
throw eoException(str);
}
file >> s;
@ -153,13 +153,13 @@ public:
loadTables(file);
} else {
string str = "nkqLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ;
throw runtime_error(str);
throw eoException(str);
}
file.close();
} else {
string str = "nkqLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw runtime_error(str);
// string str = "nkqLandscapesEval.load: Could not open file [" + _fileName + "]." ;
throw eoFileError(_fileName);
}
};
@ -192,7 +192,7 @@ public:
} else {
string fname(_fileName);
string str = "nkqLandscapesEval.save: Could not open file [" + fname + "]." ;
throw runtime_error(str);
throw eoFileError(fname);
}
};

View file

@ -52,8 +52,8 @@ public:
std::fstream file(_fileData.c_str(), std::ios::in);
if (!file) {
std::string str = "QAPeval: Could not open file [" + _fileData + "]." ;
throw std::runtime_error(str);
// std::string str = "QAPeval: Could not open file [" + _fileData + "]." ;
throw eoFileError(_fileData);
}
unsigned i, j;

View file

@ -65,8 +65,8 @@ public:
std::fstream file(_fileName.c_str(), std::ios::in);
if (!file) {
std::string str = "UbqpEval: Could not open file [" + _fileName + "]." ;
throw std::runtime_error(str);
// std::string str = "UbqpEval: Could not open file [" + _fileName + "]." ;
throw eoFileError(_fileName);
}
unsigned int nbInstances;
@ -119,7 +119,7 @@ public:
Q[i - 1][j - 1] = v;
else {
std::string str = "UbqpEval: some indices are 0 in the instance file (in format 0), please check." ;
throw std::runtime_error(str);
throw eoException(str);
}
}
} else {