(re)throw EOF exception when next_dvector() has not yet read any items

This commit is contained in:
Axel Kohlmeyer
2023-12-16 17:07:37 -05:00
parent df7f3b8dea
commit e100a42087
2 changed files with 5 additions and 2 deletions

View File

@ -144,6 +144,8 @@ void PotentialFileReader::next_dvector(double *list, int n)
{ {
try { try {
return reader->next_dvector(list, n); return reader->next_dvector(list, n);
} catch (EOFException &) {
throw EOFException("EOF reached");
} catch (FileReaderException &e) { } catch (FileReaderException &e) {
error->one(FLERR, e.what()); error->one(FLERR, e.what());
} }

View File

@ -189,8 +189,9 @@ void TextFileReader::next_dvector(double *list, int n)
char *ptr = next_line(); char *ptr = next_line();
if (ptr == nullptr) { if (ptr == nullptr) {
// EOF if (i == 0) { // EOF without any records
if (i < n) { throw EOFException("EOF reached");
} else if (i < n) { // EOF with incomplete data
throw FileReaderException( throw FileReaderException(
fmt::format("Incorrect format in {} file! {}/{} values", filetype, i, n)); fmt::format("Incorrect format in {} file! {}/{} values", filetype, i, n));
} }