tools: add catches for C++ exceptions

This commit is contained in:
Wang, Xiang W 2019-01-08 06:45:31 -05:00 committed by Chang, Harry
parent b5a8644b1f
commit 229f3d5080
2 changed files with 12 additions and 1 deletions

View File

@ -198,7 +198,15 @@ void applyGreyOverrides(Grey *g, const string &s) {
string::const_iterator ve = find(ke, pe, ';');
unsigned int value = lexical_cast<unsigned int>(string(ke + 1, ve));
unsigned int value = 0;
try {
value = lexical_cast<unsigned int>(string(ke + 1, ve));
} catch (boost::bad_lexical_cast &e) {
printf("Invalid grey override key %s:%s\n", key.c_str(),
string(ke + 1, ve).c_str());
invalid_key_seen = true;
break;
}
bool done = false;
/* surely there exists a nice template to go with this macro to make

View File

@ -1065,6 +1065,9 @@ int HS_CDECL main(int argc, char *argv[]) {
} catch (const SqlFailure &f) {
cerr << f.message << '\n';
return -1;
} catch (const std::runtime_error &e) {
cerr << "Internal error: " << e.what() << '\n';
return -1;
}
return 0;