Skip to content

Commit

Permalink
Update service/client request/response API error returns (#450)
Browse files Browse the repository at this point in the history
Signed-off-by: lobotuerk <jtlorente@ekumenlabs.com>
  • Loading branch information
Lobotuerk authored Sep 28, 2020
1 parent ac2c2fc commit f2287ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 34 deletions.
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,
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;

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

0 comments on commit f2287ea

Please sign in to comment.