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

Update service/client request/response API error returns #450

Merged
merged 7 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
33 changes: 16 additions & 17 deletions rmw_fastrtps_shared_cpp/src/rmw_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "rmw/error_handling.h"
#include "rmw/rmw.h"
#include "rmw/impl/cpp/macros.hpp"
#include "rmw/types.h"

#include "rmw_fastrtps_shared_cpp/custom_client_info.hpp"
Expand All @@ -38,17 +39,16 @@ __rmw_send_request(
const void * ros_request,
int64_t * sequence_id)
{
assert(client);
assert(ros_request);
assert(sequence_id);
RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
client handle,
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved
client->implementation_identifier, identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(ros_request, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(sequence_id, RMW_RET_INVALID_ARGUMENT);

rmw_ret_t returnedValue = RMW_RET_ERROR;
Lobotuerk marked this conversation as resolved.
Show resolved Hide resolved

if (client->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("node handle not from this implementation");
return RMW_RET_ERROR;
}

auto info = static_cast<CustomClientInfo *>(client->data);
assert(info);

Expand Down Expand Up @@ -77,18 +77,17 @@ __rmw_take_request(
void * ros_request,
bool * taken)
{
assert(service);
assert(request_header);
assert(ros_request);
assert(taken);
RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
service,
service->implementation_identifier, identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(request_header, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(ros_request, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_INVALID_ARGUMENT);

*taken = false;

if (service->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("service handle not from this implementation");
return RMW_RET_ERROR;
}

auto info = static_cast<CustomServiceInfo *>(service->data);
assert(info);

Expand Down
33 changes: 16 additions & 17 deletions rmw_fastrtps_shared_cpp/src/rmw_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "rmw/error_handling.h"
#include "rmw/rmw.h"
#include "rmw/impl/cpp/macros.hpp"

#include "rmw_fastrtps_shared_cpp/custom_client_info.hpp"
#include "rmw_fastrtps_shared_cpp/custom_service_info.hpp"
Expand All @@ -37,18 +38,17 @@ __rmw_take_response(
void * ros_response,
bool * taken)
{
assert(client);
assert(request_header);
assert(ros_response);
assert(taken);
RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
client,
client->implementation_identifier, identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(request_header, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(ros_response, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(taken, RMW_RET_INVALID_ARGUMENT);

*taken = false;

if (client->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("service handle not from this implementation");
return RMW_RET_ERROR;
}

auto info = static_cast<CustomClientInfo *>(client->data);
assert(info);

Expand Down Expand Up @@ -81,17 +81,16 @@ __rmw_send_response(
rmw_request_id_t * request_header,
void * ros_response)
{
assert(service);
assert(request_header);
assert(ros_response);
RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
service,
service->implementation_identifier, identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(request_header, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_ARGUMENT_FOR_NULL(ros_response, RMW_RET_INVALID_ARGUMENT);

rmw_ret_t returnedValue = RMW_RET_ERROR;

if (service->implementation_identifier != identifier) {
RMW_SET_ERROR_MSG("service handle not from this implementation");
return RMW_RET_ERROR;
}

auto info = static_cast<CustomServiceInfo *>(service->data);
assert(info);

Expand Down