Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"));
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/streamers/oasis/db_plugin/dbOASISReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{ }
};

Expand Down
14 changes: 7 additions & 7 deletions src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
}
}

Expand Down
Loading