Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle typesupport errors on fetch. #495

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ 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_reset_error();
type_support = get_service_typesupport_handle(
type_supports, rosidl_typesupport_introspection_cpp::typesupport_identifier);
if (!type_support) {
rcutils_reset_error();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not getting old messages here, as it is done for rmw_fastrtps_cpp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that one. Thanks @MiguelCompany !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See b45a8ec.

RMW_SET_ERROR_MSG("type support not from this implementation");
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