Skip to content

Commit aebff0d

Browse files
committed
Capture exceptions before return to user code
Signed-off-by: Yangbo Long <[email protected]>
1 parent 70ea00d commit aebff0d

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/cpp/fastdds/xtypes/dynamic_types/DynamicTypeBuilderFactoryImpl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,16 @@ traits<DynamicTypeBuilder>::ref_type DynamicTypeBuilderFactoryImpl::create_type_
6969
{
7070
traits<DynamicTypeBuilder>::ref_type ret_val;
7171

72-
idlparser::Context context = idlparser::parse_file(document, type_name, include_paths);
73-
ret_val = context.builder;
72+
try
73+
{
74+
idlparser::Context context = idlparser::parse_file(document, type_name, include_paths);
75+
ret_val = context.builder;
76+
}
77+
catch (const std::exception& e)
78+
{
79+
EPROSIMA_LOG_ERROR(IDLPARSER, e.what());
80+
ret_val.reset();
81+
}
7482

7583
return ret_val;
7684
}

src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlPreprocessor.hpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,13 @@ template<>
202202
inline std::string PreprocessorContext::preprocess_string<PreprocessorContext::preprocess_strategy::temporary_file>(
203203
const std::string& idl_string) const
204204
{
205-
std::string processed;
205+
auto os_tmp = get_temporary_file();
206206

207-
try
208-
{
209-
auto os_tmp = get_temporary_file();
210-
211-
// Populate
212-
os_tmp.first << idl_string;
213-
os_tmp.first.close();
214-
215-
processed = preprocess_file(os_tmp.second);
216-
}
217-
catch (const std::exception& e)
218-
{
219-
EPROSIMA_LOG_ERROR(IDLPARSER, "Error: " << e.what());
220-
}
207+
// Populate
208+
os_tmp.first << idl_string;
209+
os_tmp.first.close();
221210

222-
return processed;
211+
return preprocess_file(os_tmp.second);
223212
}
224213

225214
inline std::string PreprocessorContext::preprocess_string(

0 commit comments

Comments
 (0)