Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

use new error handling API from rcutils #245

Merged
merged 4 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions rmw_opensplice_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ rmw_create_node(
#ifdef _WIN32
if (!ros_domain_id) {
RMW_SET_ERROR_MSG("environment variable ROS_DOMAIN_ID is not set");
fprintf(stderr, "[rmw_opensplice_cpp]: error: %s\n", rmw_get_error_string_safe());
fprintf(stderr, "[rmw_opensplice_cpp]: error: %s\n", rmw_get_error_string().str);
return nullptr;
}
#endif
Expand Down Expand Up @@ -300,7 +300,7 @@ rmw_create_node(
if (graph_guard_condition) {
rmw_ret_t ret = rmw_destroy_guard_condition(graph_guard_condition);
if (ret != RMW_RET_OK) {
fprintf(stderr, "failed to destroy guard condition: %s\n", rmw_get_error_string_safe());
fprintf(stderr, "failed to destroy guard condition: %s\n", rmw_get_error_string().str);
}
}
if (node_info) {
Expand Down Expand Up @@ -391,7 +391,7 @@ rmw_destroy_node(rmw_node_t * node)
if (node_info->graph_guard_condition) {
rmw_ret_t ret = rmw_destroy_guard_condition(node_info->graph_guard_condition);
if (ret != RMW_RET_OK) {
fprintf(stderr, "failed to destroy guard condition: %s\n", rmw_get_error_string_safe());
fprintf(stderr, "failed to destroy guard condition: %s\n", rmw_get_error_string().str);
}
}

Expand Down
20 changes: 10 additions & 10 deletions rmw_opensplice_cpp/src/rmw_node_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ rmw_get_node_names(
rcutils_string_array_t node_list = rcutils_get_zero_initialized_string_array();
rcutils_ret_t rcutils_ret = rcutils_string_array_init(&node_list, length, &allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
rcutils_reset_error();
return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret);
}

rcutils_string_array_t ns_list = rcutils_get_zero_initialized_string_array();
rcutils_ret = rcutils_string_array_init(&ns_list, length, &allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
rcutils_reset_error();
return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret);
}
Expand All @@ -116,14 +116,14 @@ rmw_get_node_names(
std::string name(name_found->second.begin(), name_found->second.end());
node_list.data[n] = rcutils_strndup(name.c_str(), name.size(), allocator);
if (!node_list.data[n]) {
RMW_SET_ERROR_MSG("could not allocate memory for node name")
RMW_SET_ERROR_MSG("could not allocate memory for node name");
goto fail;
}

std::string ns(ns_found->second.begin(), ns_found->second.end());
ns_list.data[n] = rcutils_strndup(ns.c_str(), ns.size(), allocator);
if (!ns_list.data[n]) {
RMW_SET_ERROR_MSG("could not allocate memory for node name")
RMW_SET_ERROR_MSG("could not allocate memory for node name");
goto fail;
}
n++;
Expand All @@ -138,14 +138,14 @@ rmw_get_node_names(
// Allocate the node_names out-buffer according to the number of Node names
rcutils_ret = rcutils_string_array_init(node_names, n, &allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
rcutils_reset_error();
goto fail;
}

rcutils_ret = rcutils_string_array_init(node_namespaces, n, &allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
rcutils_reset_error();
goto fail;
}
Expand All @@ -168,28 +168,28 @@ rmw_get_node_names(
if (rcutils_ret != RCUTILS_RET_OK) {
RCUTILS_LOG_ERROR_NAMED(
"rmw_opensplice_cpp",
"failed to cleanup during error handling: %s", rcutils_get_error_string_safe());
"failed to cleanup during error handling: %s", rcutils_get_error_string().str);
rcutils_reset_error();
}
rcutils_ret = rcutils_string_array_fini(&node_list);
if (rcutils_ret != RCUTILS_RET_OK) {
RCUTILS_LOG_ERROR_NAMED(
"rmw_opensplice_cpp",
"failed to cleanup during error handling: %s", rcutils_get_error_string_safe());
"failed to cleanup during error handling: %s", rcutils_get_error_string().str);
rcutils_reset_error();
}
rcutils_ret = rcutils_string_array_fini(node_names);
if (rcutils_ret != RCUTILS_RET_OK) {
RCUTILS_LOG_ERROR_NAMED(
"rmw_opensplice_cpp",
"failed to cleanup during error handling: %s", rcutils_get_error_string_safe());
"failed to cleanup during error handling: %s", rcutils_get_error_string().str);
rcutils_reset_error();
}
rcutils_ret = rcutils_string_array_fini(node_namespaces);
if (rcutils_ret != RCUTILS_RET_OK) {
RCUTILS_LOG_ERROR_NAMED(
"rmw_opensplice_cpp",
"failed to cleanup during error handling: %s", rcutils_get_error_string_safe());
"failed to cleanup during error handling: %s", rcutils_get_error_string().str);
rcutils_reset_error();
}
return RMW_RET_BAD_ALLOC;
Expand Down
12 changes: 6 additions & 6 deletions rmw_opensplice_cpp/src/rmw_service_names_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ rmw_get_service_names_and_types(
rmw_names_and_types_t * service_names_and_types)
{
if (!allocator) {
RMW_SET_ERROR_MSG("allocator is null")
RMW_SET_ERROR_MSG("allocator is null");
return RMW_RET_INVALID_ARGUMENT;
}
if (!node) {
RMW_SET_ERROR_MSG_ALLOC("null node handle", *allocator)
RMW_SET_ERROR_MSG("null node handle");
return RMW_RET_INVALID_ARGUMENT;
}
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
Expand Down Expand Up @@ -91,7 +91,7 @@ rmw_get_service_names_and_types(
auto fail_cleanup = [&service_names_and_types]() {
rmw_ret_t rmw_ret = rmw_names_and_types_fini(service_names_and_types);
if (rmw_ret != RMW_RET_OK) {
RCUTILS_LOG_ERROR("error during report of error: %s", rmw_get_error_string_safe());
RCUTILS_LOG_ERROR("error during report of error: %s", rmw_get_error_string().str);
}
};
// For each service, store the name, initialize the string array for types, and store all types
Expand All @@ -100,7 +100,7 @@ rmw_get_service_names_and_types(
// Duplicate and store the service_name
char * service_name = rcutils_strdup(service_n_types.first.c_str(), *allocator);
if (!service_name) {
RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for service name", *allocator);
RMW_SET_ERROR_MSG("failed to allocate memory for service name");
fail_cleanup();
return RMW_RET_BAD_ALLOC;
}
Expand All @@ -112,7 +112,7 @@ rmw_get_service_names_and_types(
service_n_types.second.size(),
allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
fail_cleanup();
return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret);
}
Expand All @@ -129,7 +129,7 @@ rmw_get_service_names_and_types(
}
char * type_name = rcutils_strdup(stripped_type.c_str(), *allocator);
if (!type_name) {
RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for type name", *allocator)
RMW_SET_ERROR_MSG("failed to allocate memory for type name");
fail_cleanup();
return RMW_RET_BAD_ALLOC;
}
Expand Down
8 changes: 4 additions & 4 deletions rmw_opensplice_cpp/src/rmw_topic_names_and_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ rmw_get_topic_names_and_types(
auto fail_cleanup = [&topic_names_and_types]() {
rmw_ret_t rmw_ret = rmw_names_and_types_fini(topic_names_and_types);
if (rmw_ret != RMW_RET_OK) {
RCUTILS_LOG_ERROR("error during report of error: %s", rmw_get_error_string_safe());
RCUTILS_LOG_ERROR("error during report of error: %s", rmw_get_error_string().str);
}
};
// Setup demangling functions based on no_demangle option
Expand All @@ -106,7 +106,7 @@ rmw_get_topic_names_and_types(
// Duplicate and store the topic_name
char * topic_name = rcutils_strdup(demangle_topic(topic_n_types.first).c_str(), *allocator);
if (!topic_name) {
RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for topic name", *allocator);
RMW_SET_ERROR_MSG("failed to allocate memory for topic name");
fail_cleanup();
return RMW_RET_BAD_ALLOC;
}
Expand All @@ -118,7 +118,7 @@ rmw_get_topic_names_and_types(
topic_n_types.second.size(),
allocator);
if (rcutils_ret != RCUTILS_RET_OK) {
RMW_SET_ERROR_MSG(rcutils_get_error_string_safe())
RMW_SET_ERROR_MSG(rcutils_get_error_string().str);
fail_cleanup();
return rmw_convert_rcutils_ret_to_rmw_ret(rcutils_ret);
}
Expand All @@ -128,7 +128,7 @@ rmw_get_topic_names_and_types(
for (const auto & type : topic_n_types.second) {
char * type_name = rcutils_strdup(demangle_type(type).c_str(), *allocator);
if (!type_name) {
RMW_SET_ERROR_MSG_ALLOC("failed to allocate memory for type name", *allocator)
RMW_SET_ERROR_MSG("failed to allocate memory for type name");
fail_cleanup();
return RMW_RET_BAD_ALLOC;
}
Expand Down
4 changes: 2 additions & 2 deletions rmw_opensplice_cpp/src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ CustomPublisherListener::on_data_available(DDS::DataReader * reader)
if (data_seq.length() > 0) {
rmw_ret_t ret = rmw_trigger_guard_condition(graph_guard_condition_);
if (ret != RMW_RET_OK) {
fprintf(stderr, "failed to trigger graph guard condition: %s\n", rmw_get_error_string_safe());
fprintf(stderr, "failed to trigger graph guard condition: %s\n", rmw_get_error_string().str);
}
}

Expand Down Expand Up @@ -291,7 +291,7 @@ CustomSubscriberListener::on_data_available(DDS::DataReader * reader)
if (data_seq.length() > 0) {
rmw_ret_t ret = rmw_trigger_guard_condition(graph_guard_condition_);
if (ret != RMW_RET_OK) {
fprintf(stderr, "failed to trigger graph guard condition: %s\n", rmw_get_error_string_safe());
fprintf(stderr, "failed to trigger graph guard condition: %s\n", rmw_get_error_string().str);
}
}

Expand Down