From df97b20b6c81b0cd713d9cec0fec6b7e33dba8e0 Mon Sep 17 00:00:00 2001 From: Mikko Partio Date: Thu, 6 Jun 2024 08:45:36 +0300 Subject: [PATCH] Better error message when allowed missing value count is exceeded --- himan-plugins/source/writer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/himan-plugins/source/writer.cpp b/himan-plugins/source/writer.cpp index 9f13e930..656273dd 100644 --- a/himan-plugins/source/writer.cpp +++ b/himan-plugins/source/writer.cpp @@ -191,10 +191,14 @@ himan::HPWriteStatus writer::ToFile(std::shared_ptr> theInfo, std::share if (aggregationPeriodCheck && allowedMissing < theInfo->Data().MissingCount()) { - itsLogger.Fatal(fmt::format("Parameter {} for leadtime {} contains more missing values ({}) than allowed ({})", - theInfo->Param().Name(), theInfo->Time().Step(), theInfo->Data().MissingCount(), - allowedMissing)); - exit(1); + size_t m = theInfo->Data().MissingCount(); + double exceedance = static_cast(m - allowedMissing) / static_cast(allowedMissing) * 100.0; + + itsLogger.Fatal( + fmt::format("Parameter {} leadtime {} contains more missing values than allowed (allowed={}, missing={}, " + "exceedance={:.2f}%)", + theInfo->Param().Name(), theInfo->Time().Step(), allowedMissing, m, exceedance)); + himan::Abort(); } timer t;