Skip to content

Commit

Permalink
reset error message before setting a new one, embed the original one (r…
Browse files Browse the repository at this point in the history
…os2#501)

* reset error message before setting a new one, embed the original one

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>

* fix max line length

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
  • Loading branch information
dirk-thomas authored and zmichaels11 committed Sep 20, 2019
1 parent 6aa3eb5 commit 44ca3c2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rcl_lifecycle/src/rcl_lifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,20 @@ rcl_lifecycle_state_machine_fini(
rcl_ret_t fcn_ret = RCL_RET_OK;

if (rcl_lifecycle_com_interface_fini(&state_machine->com_interface, node_handle) != RCL_RET_OK) {
RCL_SET_ERROR_MSG("could not free lifecycle com interface. Leaking memory!\n");
rcl_error_string_t error_string = rcl_get_error_string();
rcutils_reset_error();
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
"could not free lifecycle com interface. Leaking memory!\n%s", error_string.str);
fcn_ret = RCL_RET_ERROR;
}

if (rcl_lifecycle_transition_map_fini(
&state_machine->transition_map, allocator) != RCL_RET_OK)
{
RCL_SET_ERROR_MSG("could not free lifecycle transition map. Leaking memory!\n");
rcl_error_string_t error_string = rcl_get_error_string();
rcutils_reset_error();
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
"could not free lifecycle transition map. Leaking memory!\n%s", error_string.str);
fcn_ret = RCL_RET_ERROR;
}

Expand Down Expand Up @@ -333,7 +339,9 @@ _trigger_transition(
rcl_ret_t ret = rcl_lifecycle_com_interface_publish_notification(
&state_machine->com_interface, transition->start, state_machine->current_state);
if (ret != RCL_RET_OK) {
RCL_SET_ERROR_MSG("Could not publish transition");
rcl_error_string_t error_string = rcl_get_error_string();
rcutils_reset_error();
RCL_SET_ERROR_MSG_WITH_FORMAT_STRING("Could not publish transition: %s", error_string.str);
return RCL_RET_ERROR;
}
}
Expand Down

0 comments on commit 44ca3c2

Please sign in to comment.