Skip to content

expose error handling for state changes#344

Merged
Karsten1987 merged 3 commits intomasterfrom
error_handling
Jul 27, 2017
Merged

expose error handling for state changes#344
Karsten1987 merged 3 commits intomasterfrom
error_handling

Conversation

@Karsten1987
Copy link
Copy Markdown
Contributor

two changes in this PR:

1.) remove fprintfs and replace them with RCUTILS_LOG..
2.) every state change has now an additional parameter to see whether the action went to an erroneous state while transitioning.

CI:
linux: Build Status
osx: Build Status
windows: Build Status

@Karsten1987 Karsten1987 added the in review Waiting for review (Kanban column) label Jul 25, 2017
@Karsten1987 Karsten1987 self-assigned this Jul 25, 2017
resp->success = change_state(req->transition.id);
rcl_lifecycle_ret_t error;
auto ret = change_state(req->transition.id, error);
(void) error;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you should call this callback_return_code or something. error is not very descriptive.

// error handling ?!
// TODO(karsten1987): iterate over possible ret value
if (cb_success == RCL_LIFECYCLE_RET_ERROR) {
RCUTILS_LOG_WARN("Error occured. Executing error handling.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick, I don't think this should be two sentences, instead maybe "Error occurred while doing error handling". (also occurred is misspelled)

const State &
trigger_transition(const Transition & transition);

RCLCPP_LIFECYCLE_PUBLIC
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this function getting a rcl_ret_t argument while the other functions get a rcl_lifecycle_ret_t?

return impl_->trigger_transition(transition_id);
}

const State &
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This signature doesn't match the header (rcl_ret_t vs. rcl_lifecycle_ret_t)?

rcl_lifecycle_ret_t error;
auto ret = change_state(req->transition.id, error);
(void) error;
resp->success = (ret == RCL_RET_OK) ? true : false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The expression in the parenthesis is already the boolean you want. No need to the ternary operator here.

if (rcl_lifecycle_trigger_transition(&state_machine_, error_resolved, true) != RCL_RET_OK) {
fprintf(stderr, "Failed to call cleanup on error state\n");
return false;
RCUTILS_LOG_ERROR("Failed to call cleanup on error state");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No semicolon after logging macros.

Same below.

@Karsten1987
Copy link
Copy Markdown
Contributor Author

I hopefully addressed all comments. If nobody has further comments until tomorrow afternoon, i'll go ahead and merge.

ran a new batch of ci:

linux: Build Status
osx: Build Status
win: Build Status

@Karsten1987 Karsten1987 merged commit 0c26dd9 into master Jul 27, 2017
@Karsten1987 Karsten1987 deleted the error_handling branch July 27, 2017 14:55
@Karsten1987 Karsten1987 removed the in review Waiting for review (Kanban column) label Jul 27, 2017
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants