Skip to content

Commit

Permalink
Print a hint on what might be wrong when retrieveSeries fails (#1610)
Browse files Browse the repository at this point in the history
* Print a hint on what might be wrong when retrieveSeries fails

* add parentheses
  • Loading branch information
franzpoeschel committed Apr 22, 2024
1 parent 9e53e9a commit 805c760
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/backend/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <iostream>
#include <set>
#include <sstream>
#include <stdexcept>

namespace openPMD
{
Expand Down Expand Up @@ -126,8 +127,17 @@ Series Attributable::retrieveSeries() const
{
findSeries = findSeries->parent;
}
auto seriesData = &auxiliary::deref_dynamic_cast<internal::SeriesData>(
findSeries->attributable);
auto *seriesData =
dynamic_cast<internal::SeriesData *>(findSeries->attributable);
if (!seriesData)
{
throw std::runtime_error(
"[Attributable::retrieveSeries] Error when trying to retrieve the "
"Series object. Note: An instance of the Series object must still "
"exist when flushing. A common cause for this error is using a "
"flush call on a handle (e.g. `Iteration::seriesFlush()`) when the "
"original Series object has already gone out of scope.");
}
Series res;
res.setData(
std::shared_ptr<internal::SeriesData>{seriesData, [](auto const *) {}});
Expand Down

0 comments on commit 805c760

Please sign in to comment.