diff --git a/src/cpp/fastdds/xtypes/dynamic_types/DynamicTypeBuilderFactoryImpl.cpp b/src/cpp/fastdds/xtypes/dynamic_types/DynamicTypeBuilderFactoryImpl.cpp index 0710d06c699..75e9954f7cf 100644 --- a/src/cpp/fastdds/xtypes/dynamic_types/DynamicTypeBuilderFactoryImpl.cpp +++ b/src/cpp/fastdds/xtypes/dynamic_types/DynamicTypeBuilderFactoryImpl.cpp @@ -69,8 +69,16 @@ traits::ref_type DynamicTypeBuilderFactoryImpl::create_type_ { traits::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; } diff --git a/src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp b/src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp index b4fc4fe9a75..1d7b77fc678 100644 --- a/src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp +++ b/src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp @@ -202,24 +202,13 @@ template<> inline std::string PreprocessorContext::preprocess_string( 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(