@@ -112,16 +112,28 @@ void
112
112
SubscriptionBase::bind_event_callbacks (
113
113
const SubscriptionEventCallbacks & event_callbacks, bool use_default_callbacks)
114
114
{
115
- if (event_callbacks.deadline_callback ) {
116
- this ->add_event_handler (
117
- event_callbacks.deadline_callback ,
118
- RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED);
115
+ try {
116
+ if (event_callbacks.deadline_callback ) {
117
+ this ->add_event_handler (
118
+ event_callbacks.deadline_callback ,
119
+ RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED);
120
+ }
121
+ } catch (const UnsupportedEventTypeException & /* exc*/ ) {
122
+ RCLCPP_WARN (
123
+ rclcpp::get_logger (" rclcpp" ),
124
+ " Failed to add event handler for deadline; not supported" );
119
125
}
120
126
121
- if (event_callbacks.liveliness_callback ) {
122
- this ->add_event_handler (
123
- event_callbacks.liveliness_callback ,
124
- RCL_SUBSCRIPTION_LIVELINESS_CHANGED);
127
+ try {
128
+ if (event_callbacks.liveliness_callback ) {
129
+ this ->add_event_handler (
130
+ event_callbacks.liveliness_callback ,
131
+ RCL_SUBSCRIPTION_LIVELINESS_CHANGED);
132
+ }
133
+ } catch (const UnsupportedEventTypeException & /* exc*/ ) {
134
+ RCLCPP_WARN (
135
+ rclcpp::get_logger (" rclcpp" ),
136
+ " Failed to add event handler for liveliness; not supported" );
125
137
}
126
138
127
139
QOSRequestedIncompatibleQoSCallbackType incompatible_qos_cb;
@@ -139,7 +151,9 @@ SubscriptionBase::bind_event_callbacks(
139
151
this ->add_event_handler (incompatible_qos_cb, RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS);
140
152
}
141
153
} catch (const UnsupportedEventTypeException & /* exc*/ ) {
142
- // pass
154
+ RCLCPP_WARN (
155
+ rclcpp::get_logger (" rclcpp" ),
156
+ " Failed to add event handler for incompatible qos; not supported" );
143
157
}
144
158
145
159
IncompatibleTypeCallbackType incompatible_type_cb;
@@ -156,18 +170,33 @@ SubscriptionBase::bind_event_callbacks(
156
170
this ->add_event_handler (incompatible_type_cb, RCL_SUBSCRIPTION_INCOMPATIBLE_TYPE);
157
171
}
158
172
} catch (UnsupportedEventTypeException & /* exc*/ ) {
159
- // pass
173
+ RCLCPP_WARN (
174
+ rclcpp::get_logger (" rclcpp" ),
175
+ " Failed to add event handler for incompatible type; not supported" );
160
176
}
161
177
162
- if (event_callbacks.message_lost_callback ) {
163
- this ->add_event_handler (
164
- event_callbacks.message_lost_callback ,
165
- RCL_SUBSCRIPTION_MESSAGE_LOST);
178
+ try {
179
+ if (event_callbacks.message_lost_callback ) {
180
+ this ->add_event_handler (
181
+ event_callbacks.message_lost_callback ,
182
+ RCL_SUBSCRIPTION_MESSAGE_LOST);
183
+ }
184
+ } catch (const UnsupportedEventTypeException & /* exc*/ ) {
185
+ RCLCPP_WARN (
186
+ rclcpp::get_logger (" rclcpp" ),
187
+ " Failed to add event handler for message lost; not supported" );
166
188
}
167
- if (event_callbacks.matched_callback ) {
168
- this ->add_event_handler (
169
- event_callbacks.matched_callback ,
170
- RCL_SUBSCRIPTION_MATCHED);
189
+
190
+ try {
191
+ if (event_callbacks.matched_callback ) {
192
+ this ->add_event_handler (
193
+ event_callbacks.matched_callback ,
194
+ RCL_SUBSCRIPTION_MATCHED);
195
+ }
196
+ } catch (const UnsupportedEventTypeException & /* exc*/ ) {
197
+ RCLCPP_WARN (
198
+ rclcpp::get_logger (" rclcpp" ),
199
+ " Failed to add event handler for matched; not supported" );
171
200
}
172
201
}
173
202
0 commit comments