Skip to content

Commit 805c760

Browse files
Print a hint on what might be wrong when retrieveSeries fails (#1610)
* Print a hint on what might be wrong when retrieveSeries fails * add parentheses
1 parent 9e53e9a commit 805c760

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/Attributable.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <iostream>
3030
#include <set>
3131
#include <sstream>
32+
#include <stdexcept>
3233

3334
namespace openPMD
3435
{
@@ -126,8 +127,17 @@ Series Attributable::retrieveSeries() const
126127
{
127128
findSeries = findSeries->parent;
128129
}
129-
auto seriesData = &auxiliary::deref_dynamic_cast<internal::SeriesData>(
130-
findSeries->attributable);
130+
auto *seriesData =
131+
dynamic_cast<internal::SeriesData *>(findSeries->attributable);
132+
if (!seriesData)
133+
{
134+
throw std::runtime_error(
135+
"[Attributable::retrieveSeries] Error when trying to retrieve the "
136+
"Series object. Note: An instance of the Series object must still "
137+
"exist when flushing. A common cause for this error is using a "
138+
"flush call on a handle (e.g. `Iteration::seriesFlush()`) when the "
139+
"original Series object has already gone out of scope.");
140+
}
131141
Series res;
132142
res.setData(
133143
std::shared_ptr<internal::SeriesData>{seriesData, [](auto const *) {}});

0 commit comments

Comments
 (0)