From 9953ce737aa244fd6930fa5f713978506bfe155a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 23 Aug 2026 15:58:53 +0200 Subject: [PATCH 1/2] Removing cell name from OASIS error message or warning if not inside a cell --- .../streamers/oasis/db_plugin/dbOASISReader.cc | 16 +++++++++++----- .../streamers/oasis/db_plugin/dbOASISReader.h | 5 ++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc index 124df7e44..46d93413a 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc @@ -446,7 +446,7 @@ OASISReader::get_gdelta (int64_t grid) void OASISReader::error (const std::string &msg) { - throw OASISReaderException (msg, m_stream.pos (), m_cellname.c_str (), m_stream.source ()); + throw OASISReaderException (msg, m_stream.pos (), m_cellname, m_stream.source ()); } void @@ -468,10 +468,16 @@ OASISReader::warn (const std::string &msg, int wl) int ws = compress_warning (msg); if (ws < 0) { - tl::warn << msg - << tl::to_string (tr (" (position=")) << m_stream.pos () - << tl::to_string (tr (", cell=")) << m_cellname - << ")"; + if (m_cellname.empty ()) { + tl::warn << msg + << tl::to_string (tr (" (position=")) << m_stream.pos () + << ")"; + } else { + tl::warn << msg + << tl::to_string (tr (" (position=")) << m_stream.pos () + << tl::to_string (tr (", cell=")) << m_cellname + << ")"; + } } else if (ws == 0) { tl::warn << tl::to_string (tr ("... further warnings of this kind are not shown")); } diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h index 4420e6c45..a085d1bac 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h @@ -55,7 +55,10 @@ class DB_PLUGIN_PUBLIC OASISReaderException { public: OASISReaderException (const std::string &msg, size_t p, const std::string &cell, const std::string &source) - : ReaderException (tl::sprintf (tl::to_string (tr ("%s (position=%ld, cell=%s), in file: %s")), msg, p, cell, source)) + : ReaderException ( + cell.empty () ? + tl::sprintf (tl::to_string (tr ("%s (position=%ld), in file: %s")), msg, p, source) + : tl::sprintf (tl::to_string (tr ("%s (position=%ld, cell=%s), in file: %s")), msg, p, cell, source)) { } }; From 4959edc2bfbe588931451a3b248f2adc2203c611 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 23 Aug 2026 16:41:14 +0200 Subject: [PATCH 2/2] Fixing unit tests --- .../oasis/unit_tests/dbOASISReaderTests.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc index e73fe153b..0c8516b91 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc @@ -198,12 +198,12 @@ TEST(11_7) TEST(11_8) { - run_test_error (_this, "11.8", "Modal variable accessed before being defined: last-value-list (position=96, cell=)"); + run_test_error (_this, "11.8", "Modal variable accessed before being defined: last-value-list (position=96)"); } TEST(11_9) { - run_test_error (_this, "11.9", "Modal variable accessed before being defined: last-value-list (position=118, cell=)"); + run_test_error (_this, "11.9", "Modal variable accessed before being defined: last-value-list (position=118)"); } TEST(12_1) @@ -248,7 +248,7 @@ TEST(2_2) TEST(2_3) { - run_test_error (_this, "2.3", "Explicit and implicit CELLNAME modes cannot be mixed (position=45, cell=)"); + run_test_error (_this, "2.3", "Explicit and implicit CELLNAME modes cannot be mixed (position=45)"); } TEST(2_4) @@ -258,7 +258,7 @@ TEST(2_4) TEST(2_5) { - run_test_error (_this, "2.5", "No cellname defined for cell name id 2 (position=305, cell=)"); + run_test_error (_this, "2.5", "No cellname defined for cell name id 2 (position=305)"); } TEST(2_6) @@ -298,12 +298,12 @@ TEST(3_2) TEST(3_3) { - run_test_error (_this, "3.3", "Explicit and implicit TEXTSTRING modes cannot be mixed (position=41, cell=)"); + run_test_error (_this, "3.3", "Explicit and implicit TEXTSTRING modes cannot be mixed (position=41)"); } TEST(3_4) { - run_test_error (_this, "3.4", "No text string defined for text string id 2 (position=309, cell=)"); + run_test_error (_this, "3.4", "No text string defined for text string id 2 (position=309)"); } TEST(3_5) @@ -636,7 +636,7 @@ TEST(Bug_1474) // Seen when private test data is not installed throw; } catch (tl::Exception &ex) { - EXPECT_EQ (ex.msg ().find ("Cell named ADDHX2 with ID 4 was already given name SEDFFTRX2 (position=763169, cell=)"), size_t (0)); + EXPECT_EQ (ex.msg ().find ("Cell named ADDHX2 with ID 4 was already given name SEDFFTRX2 (position=763169)"), size_t (0)); } }