Skip to content

Commit 4a3b176

Browse files
committed
catching errors when parsing stream_options DDS message
1 parent defc7dd commit 4a3b176

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

third-party/realdds/src/dds-device-impl.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,18 @@ void dds_device::impl::on_stream_options( json const & j, dds_sample const & sam
847847
dds_options options;
848848
for( auto & option_j : options_j )
849849
{
850-
//LOG_DEBUG( "[" << debug_name() << "] ... " << option_j );
851-
auto option = dds_option::from_json( option_j );
852-
options.push_back( option );
850+
try
851+
{
852+
//LOG_DEBUG( "[" << debug_name() << "] ... " << option_j );
853+
auto option = dds_option::from_json( option_j );
854+
options.push_back( option );
855+
}
856+
catch( std::exception const& e )
857+
{
858+
LOG_ERROR("[" << debug_name() << "] Invalid option for stream " << stream->name()
859+
<< ". Error: " << e.what() << ", reading" << option_j);
860+
}
853861
}
854-
855862
stream->init_options( options );
856863
}
857864

@@ -895,10 +902,17 @@ void dds_device::impl::on_stream_options( json const & j, dds_sample const & sam
895902
dds_embedded_filters embedded_filters;
896903
for (auto& embedded_filter_j : embedded_filters_j)
897904
{
898-
auto embedded_filter = dds_embedded_filter::from_json(embedded_filter_j);
899-
embedded_filters.push_back(embedded_filter);
905+
try
906+
{
907+
auto embedded_filter = dds_embedded_filter::from_json(embedded_filter_j);
908+
embedded_filters.push_back(embedded_filter);
909+
}
910+
catch (std::exception const& e)
911+
{
912+
LOG_ERROR("[" << debug_name() << "] Invalid embedded filter for stream " << stream->name()
913+
<< ". Error: " << e.what() << ", reading" << embedded_filter_j);
914+
}
900915
}
901-
902916
stream->init_embedded_filters(std::move(embedded_filters));
903917
}
904918

0 commit comments

Comments
 (0)