From e100a42087f0bf75a815fbe95cd837ba8ac2d22b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 16 Dec 2023 17:07:37 -0500 Subject: [PATCH] (re)throw EOF exception when next_dvector() has not yet read any items --- src/potential_file_reader.cpp | 2 ++ src/text_file_reader.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index 2c0b9a6a55..613225a797 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -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()); } diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index 46a5fd33a9..0b8d717687 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -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)); }