Skip to content

Commit

Permalink
Added debug statements into try/catch blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed May 16, 2024
1 parent eff6fd9 commit ee3e0cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 9 additions & 1 deletion plugins/liberty_parser/src/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PinDirection>(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")
Expand Down Expand Up @@ -1314,4 +1322,4 @@ namespace hal

return OK(res);
}
} // namespace hal
} // namespace hal
5 changes: 2 additions & 3 deletions plugins/liberty_parser/test/liberty_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee3e0cb

Please sign in to comment.