Skip to content

Commit

Permalink
Capture exceptions before return to user code
Browse files Browse the repository at this point in the history
Signed-off-by: Yangbo Long <yangbo.long.mav@gmail.com>
  • Loading branch information
YangboLong committed Sep 6, 2024
1 parent bfde524 commit 489efaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ traits<DynamicTypeBuilder>::ref_type DynamicTypeBuilderFactoryImpl::create_type_
{
traits<DynamicTypeBuilder>::ref_type ret_val;

idlparser::Context context = idlparser::parse_file(document, type_name, include_paths);
ret_val = context.builder;
try
{
idlparser::Context context = idlparser::parse_file(document, type_name, include_paths);
ret_val = context.builder;
}
catch (const std::exception& e)
{
EPROSIMA_LOG_ERROR(IDLPARSER, e.what());
ret_val.reset();
}

return ret_val;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,13 @@ template<>
inline std::string PreprocessorContext::preprocess_string<PreprocessorContext::preprocess_strategy::temporary_file>(
const std::string& idl_string) const
{
std::string processed;
auto os_tmp = get_temporary_file();

try
{
auto os_tmp = get_temporary_file();

// Populate
os_tmp.first << idl_string;
os_tmp.first.close();

processed = preprocess_file(os_tmp.second);
}
catch (const std::exception& e)
{
EPROSIMA_LOG_ERROR(IDLPARSER, "Error: " << e.what());
}
// Populate
os_tmp.first << idl_string;
os_tmp.first.close();

return processed;
return preprocess_file(os_tmp.second);
}

inline std::string PreprocessorContext::preprocess_string(
Expand Down

0 comments on commit 489efaf

Please sign in to comment.