From ceefeea4289075d94d7c0703901e69c8d951a620 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 29 Jul 2022 17:03:19 +0100 Subject: [PATCH] Error handling: Add a user-friendly error message --- src/grib_ieeefloat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/grib_ieeefloat.c b/src/grib_ieeefloat.c index 82f20349f..445b1a6aa 100644 --- a/src/grib_ieeefloat.c +++ b/src/grib_ieeefloat.c @@ -306,8 +306,12 @@ int grib_nearest_smaller_ieee_float(double a, double* ret) init_table_if_needed(); - if (a > ieee_table.vmax) + if (a > ieee_table.vmax) { + grib_context* c = grib_context_get_default(); + grib_context_log(c, GRIB_LOG_ERROR, + "Number is too large: x=%e > xmax=%e (IEEE float)", a, ieee_table.vmax); return GRIB_INTERNAL_ERROR; + } l = grib_ieee_nearest_smaller_to_long(a); *ret = grib_long_to_ieee(l);