(re)throw EOF exception when next_dvector() has not yet read any items
This commit is contained in:
@ -144,6 +144,8 @@ void PotentialFileReader::next_dvector(double *list, int n)
|
||||
{
|
||||
try {
|
||||
return reader->next_dvector(list, n);
|
||||
} catch (EOFException &) {
|
||||
throw EOFException("EOF reached");
|
||||
} catch (FileReaderException &e) {
|
||||
error->one(FLERR, e.what());
|
||||
}
|
||||
|
||||
@ -189,8 +189,9 @@ void TextFileReader::next_dvector(double *list, int n)
|
||||
char *ptr = next_line();
|
||||
|
||||
if (ptr == nullptr) {
|
||||
// EOF
|
||||
if (i < n) {
|
||||
if (i == 0) { // EOF without any records
|
||||
throw EOFException("EOF reached");
|
||||
} else if (i < n) { // EOF with incomplete data
|
||||
throw FileReaderException(
|
||||
fmt::format("Incorrect format in {} file! {}/{} values", filetype, i, n));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user