Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## main

* **Fixed**
* Improved error message when reading values from time history database fails.

## Version 4.0.1 (2026/08/17)

* **Added**
Expand Down
12 changes: 10 additions & 2 deletions libsrc/spatialdata/spatialdb/TimeHistoryIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime,
double* time = (size > 0) ? new double[size] : 0;
double* amplitude = (size > 0) ? new double[size] : 0;

for (size_t i = 0; i < size; ++i) {
int count = 0;
for (size_t i = 0; i < size; ++i, ++count) {
buffer.str(parser.next());
buffer.clear();
buffer >> time[i];
Expand All @@ -140,7 +141,14 @@ spatialdata::spatialdb::TimeHistoryIO::read(double** ptime,
} // for

if (!filein.good()) {
throw std::runtime_error("Unknown error while reading.");
std::ostringstream msg;
if (count < size) {
msg << "Read " << count << " out of " << size << " points before encountering the I/O error.";
} else {
msg << "Error occurred while reading data for final point.\n"
<< "Make sure that the last line with data ends with an end-of-line character.";
} // if/else
throw std::runtime_error(msg.str());
} // if

delete[] *ptime;*ptime = time;
Expand Down
Loading