From 11fef5f9e8b6e71ccfefaab156dd795cc25323b3 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Fri, 10 Jan 2025 16:10:57 +0000 Subject: [PATCH] eckit::geo grib_iterator_new explicit eckit::geo::Exception handling --- src/geo/iterator/grib_iterator.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/geo/iterator/grib_iterator.cc b/src/geo/iterator/grib_iterator.cc index b850623f2..cec93215f 100644 --- a/src/geo/iterator/grib_iterator.cc +++ b/src/geo/iterator/grib_iterator.cc @@ -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() @@ -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(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;