Add missing try-catch

This commit is contained in:
Richard Berger
2020-06-02 18:37:04 -04:00
parent 18bb4bfdc2
commit 185eeaea8b
3 changed files with 41 additions and 32 deletions

View File

@ -506,9 +506,9 @@ void AngleTable::param_extract(Table *tb, char *line)
tb->fpflag = 0; tb->fpflag = 0;
tb->theta0 = MY_PI; tb->theta0 = MY_PI;
ValueTokenizer values(line);
try { try {
ValueTokenizer values(line);
while (values.has_next()) { while (values.has_next()) {
std::string word = values.next_string(); std::string word = values.next_string();

View File

@ -476,21 +476,26 @@ void BondTable::param_extract(Table *tb, char *line)
tb->fpflag = 0; tb->fpflag = 0;
tb->r0 = 0.0; tb->r0 = 0.0;
ValueTokenizer values(line); try {
while (values.has_next()) { ValueTokenizer values(line);
std::string word = values.next_string();
if (word == "N") { while (values.has_next()) {
tb->ninput = values.next_int(); std::string word = values.next_string();
} else if (word == "FP") {
tb->fpflag = 1; if (word == "N") {
tb->fplo = values.next_double(); tb->ninput = values.next_int();
tb->fphi = values.next_double(); } else if (word == "FP") {
} else if (word == "EQ") { tb->fpflag = 1;
tb->r0 = values.next_double(); tb->fplo = values.next_double();
} else { tb->fphi = values.next_double();
error->one(FLERR,"Invalid keyword in bond table parameters"); } else if (word == "EQ") {
tb->r0 = values.next_double();
} else {
error->one(FLERR,"Invalid keyword in bond table parameters");
}
} }
} catch(TokenizerException & e) {
error->one(FLERR, e.what());
} }
if (tb->ninput == 0) error->one(FLERR,"Bond table parameters did not set N"); if (tb->ninput == 0) error->one(FLERR,"Bond table parameters did not set N");

View File

@ -557,25 +557,29 @@ void PairTable::param_extract(Table *tb, char *line)
tb->rflag = NONE; tb->rflag = NONE;
tb->fpflag = 0; tb->fpflag = 0;
ValueTokenizer values(line); try {
ValueTokenizer values(line);
while (values.has_next()) { while (values.has_next()) {
std::string word = values.next_string(); std::string word = values.next_string();
if (word == "N") { if (word == "N") {
tb->ninput = values.next_int(); tb->ninput = values.next_int();
} else if ((word == "R") || (word == "RSQ") || (word == "BITMAP")) { } else if ((word == "R") || (word == "RSQ") || (word == "BITMAP")) {
if (word == "R") tb->rflag = RLINEAR; if (word == "R") tb->rflag = RLINEAR;
else if (word == "RSQ") tb->rflag = RSQ; else if (word == "RSQ") tb->rflag = RSQ;
else if (word == "BITMAP") tb->rflag = BMP; else if (word == "BITMAP") tb->rflag = BMP;
tb->rlo = values.next_double(); tb->rlo = values.next_double();
tb->rhi = values.next_double(); tb->rhi = values.next_double();
} else if (word == "FPRIME") { } else if (word == "FPRIME") {
tb->fpflag = 1; tb->fpflag = 1;
tb->fplo = values.next_double(); tb->fplo = values.next_double();
tb->fphi = values.next_double(); tb->fphi = values.next_double();
} else { } else {
error->one(FLERR,fmt::format("Invalid keyword {} in pair table parameters", word).c_str()); error->one(FLERR,fmt::format("Invalid keyword {} in pair table parameters", word).c_str());
}
} }
} catch (TokenizerException & e) {
error->one(FLERR, e.what());
} }
if (tb->ninput == 0) error->one(FLERR,"Pair table parameters did not set N"); if (tb->ninput == 0) error->one(FLERR,"Pair table parameters did not set N");