(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 {
|
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());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user