Skip to content

Commit

Permalink
Handle typesupport errors on fetch. (#495)
Browse files Browse the repository at this point in the history
* Handle typesupport errors on fetch.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic authored Dec 15, 2020
1 parent 6a19fc8 commit c3b958e
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 8 deletions.
12 changes: 11 additions & 1 deletion rmw_fastrtps_cpp/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "fastrtps/Domain.h"
#include "fastrtps/participant/Participant.h"

#include "rcutils/error_handling.h"
#include "rcutils/macros.h"

#include "rmw/allocators.h"
Expand Down Expand Up @@ -84,10 +85,19 @@ rmw_fastrtps_cpp::create_publisher(
const rosidl_message_type_support_t * type_support = get_message_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_C);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_message_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_CPP);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
12 changes: 11 additions & 1 deletion rmw_fastrtps_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <string>

#include "rcpputils/scope_exit.hpp"
#include "rcutils/error_handling.h"
#include "rcutils/logging_macros.h"

#include "rmw/allocators.h"
Expand Down Expand Up @@ -81,10 +82,19 @@ rmw_create_client(
const rosidl_service_type_support_t * type_support = get_service_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_C);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_service_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_CPP);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
12 changes: 11 additions & 1 deletion rmw_fastrtps_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <vector>

#include "rcpputils/scope_exit.hpp"
#include "rcutils/error_handling.h"
#include "rcutils/logging_macros.h"

#include "rmw/allocators.h"
Expand Down Expand Up @@ -93,10 +94,19 @@ rmw_create_service(
const rosidl_service_type_support_t * type_support = get_service_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_C);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_service_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_CPP);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
12 changes: 11 additions & 1 deletion rmw_fastrtps_cpp/src/subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <utility>

#include "rcutils/allocator.h"
#include "rcutils/error_handling.h"
#include "rcutils/macros.h"
#include "rcutils/strdup.h"

Expand Down Expand Up @@ -88,10 +89,19 @@ create_subscription(
const rosidl_message_type_support_t * type_support = get_message_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_C);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_message_typesupport_handle(
type_supports, RMW_FASTRTPS_CPP_TYPESUPPORT_CPP);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
13 changes: 12 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <string>

#include "rcutils/error_handling.h"

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/rmw.h"
Expand Down Expand Up @@ -82,10 +84,19 @@ rmw_fastrtps_dynamic_cpp::create_publisher(
const rosidl_message_type_support_t * type_support = get_message_typesupport_handle(
type_supports, rosidl_typesupport_introspection_c__identifier);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_message_typesupport_handle(
type_supports, rosidl_typesupport_introspection_cpp::typesupport_identifier);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
11 changes: 10 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,19 @@ rmw_create_client(
const rosidl_service_type_support_t * type_support = get_service_typesupport_handle(
type_supports, rosidl_typesupport_introspection_c__identifier);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_service_typesupport_handle(
type_supports, rosidl_typesupport_introspection_cpp::typesupport_identifier);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
12 changes: 11 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <string>
#include <vector>

#include "rcutils/error_handling.h"
#include "rcutils/logging_macros.h"

#include "rmw/allocators.h"
Expand Down Expand Up @@ -108,10 +109,19 @@ rmw_create_service(
const rosidl_service_type_support_t * type_support = get_service_typesupport_handle(
type_supports, rosidl_typesupport_introspection_c__identifier);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_service_typesupport_handle(
type_supports, rosidl_typesupport_introspection_cpp::typesupport_identifier);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down
13 changes: 12 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <string>
#include <utility>

#include "rcutils/error_handling.h"

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/rmw.h"
Expand Down Expand Up @@ -88,10 +90,19 @@ create_subscription(
const rosidl_message_type_support_t * type_support = get_message_typesupport_handle(
type_supports, rosidl_typesupport_introspection_c__identifier);
if (!type_support) {
rcutils_error_string_t prev_error_string = rcutils_get_error_string();
rcutils_reset_error();
type_support = get_message_typesupport_handle(
type_supports, rosidl_typesupport_introspection_cpp::typesupport_identifier);
if (!type_support) {
RMW_SET_ERROR_MSG("type support not from this implementation");
rcutils_error_string_t error_string = rcutils_get_error_string();
rcutils_reset_error();
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Type support not from this implementation. Got:\n"
" %s\n"
" %s\n"
"while fetching it",
prev_error_string.str, error_string.str);
return nullptr;
}
}
Expand Down

0 comments on commit c3b958e

Please sign in to comment.