From ee3e0cbce3cc701eb61510ad8dafe555fd4d0413 Mon Sep 17 00:00:00 2001 From: joern274 Date: Thu, 16 May 2024 11:33:25 +0200 Subject: [PATCH] Added debug statements into try/catch blocks --- plugins/liberty_parser/src/liberty_parser.cpp | 10 +++++++++- plugins/liberty_parser/test/liberty_parser.cpp | 5 ++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/liberty_parser/src/liberty_parser.cpp b/plugins/liberty_parser/src/liberty_parser.cpp index df6ae097d3e..d4ca5e244b9 100644 --- a/plugins/liberty_parser/src/liberty_parser.cpp +++ b/plugins/liberty_parser/src/liberty_parser.cpp @@ -418,12 +418,20 @@ namespace hal auto direction_str = pin_str.consume().string; try { + std::cerr << "Pin direction <" << direction_str << ">" << std::endl; pin.direction = enum_from_string(direction_str); } catch (const std::runtime_error&) { + std::cerr << "Exception type runtime_error" << std::endl; return ERR("could not parse pin: invalid pin direction '" + direction_str + "' (line " + std::to_string(pin.line_number) + ")"); } + catch (...) + { + std::cerr << "Exception type unknown" << std::endl; + return ERR("could not parse pin: invalid pin direction '" + direction_str + "' (line " + std::to_string(pin.line_number) + ")"); + } + pin_str.consume(";", true); } else if (next_token == "function") @@ -1314,4 +1322,4 @@ namespace hal return OK(res); } -} // namespace hal \ No newline at end of file +} // namespace hal diff --git a/plugins/liberty_parser/test/liberty_parser.cpp b/plugins/liberty_parser/test/liberty_parser.cpp index c169b71696a..222b80973a5 100644 --- a/plugins/liberty_parser/test/liberty_parser.cpp +++ b/plugins/liberty_parser/test/liberty_parser.cpp @@ -403,9 +403,8 @@ namespace hal { NO_COUT_TEST_BLOCK; std::string path_lib = utils::get_base_directory().string() + "/bin/hal_plugins/test-files/liberty_parser/invalid_test6.lib"; LibertyParser liberty_parser; - bool result_is_error = false; - ASSERT_THROW({auto gl_res = liberty_parser.parse(path_lib); result_is_error = gl_res.is_error();},std::runtime_error); - ASSERT_TRUE(result_is_error); + auto gl_res = liberty_parser.parse(path_lib); + ASSERT_TRUE(gl_res.is_error()); } // { // NOTE: Works (is ok?) // // Use an unknown variable in a boolean function