Skip to content

Commit

Permalink
eckit::geo grib_iterator_new explicit eckit::geo::Exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Jan 23, 2025
1 parent 930d569 commit 11fef5f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/geo/iterator/grib_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int

#if defined(HAVE_ECKIT_GEO)
const int eckit_geo = ch->context->eckit_geo; // check environment variable
if (eckit_geo) {
if (eckit_geo != 0) {
struct InitMain
{
InitMain()
Expand All @@ -126,10 +126,15 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int
}
}
} static const init_main;

try {
i->iterator = new eccodes::geo::GeoIterator(const_cast<grib_handle*>(ch), flags);
}
catch(std::exception& e) {
catch (eckit::geo::Exception& e) {
grib_context_log(ch->context, GRIB_LOG_FATAL, "grib_iterator_new: geo::Exception thrown (%s)", e.what());
return 0;
}
catch (std::exception& e) {
grib_context_log(ch->context, GRIB_LOG_ERROR, "grib_iterator_new: Exception thrown (%s)", e.what());
*error = GRIB_GEOCALCULUS_PROBLEM;
return NULL;
Expand Down

0 comments on commit 11fef5f

Please sign in to comment.