Skip to content

Commit

Permalink
change exception message for windows ci bug
Browse files Browse the repository at this point in the history
change exception message for windows ci bug
  • Loading branch information
Karsten1987 committed Dec 14, 2016
1 parent cde558a commit 436514a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 6 additions & 4 deletions rclcpp_lifecycle/src/lifecycle_node_interface_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,12 @@ class LifecycleNode::LifecycleNodeInterfaceImpl
auto callback = it->second;
try {
cb_success = callback(State(previous_state));
} catch (const std::exception & e) {
fprintf(stderr, "Caught exception in callback for transition %d\n",
it->first);
fprintf(stderr, "Original error msg: %s\n", e.what());
} catch (const std::exception &) {
// TODO(karsten1987): Windows CI doens't let me print the msg here
// the todo is to forward the exception to the on_error callback
// fprintf(stderr, "Caught exception in callback for transition %d\n",
// it->first);
// fprintf(stderr, "Original error msg: %s\n", e.what());
// maybe directly go for error handling here
// and pass exception along with it
cb_success = RCL_LIFECYCLE_RET_ERROR;
Expand Down
12 changes: 4 additions & 8 deletions rclcpp_lifecycle/test/test_callback_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ class PositiveCallbackExceptionNode : public rclcpp_lifecycle::LifecycleNode
rcl_lifecycle_ret_t on_configure(const rclcpp_lifecycle::State &)
{
++number_of_callbacks;
throw std::runtime_error("On_configure exception");
throw std::runtime_error("custom exception raised in configure callback");
}

rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State & previous_state)
rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State &)
{
fprintf(stderr, "Previous state of error was %s\n",
previous_state.label().c_str());
++number_of_callbacks;
return RCL_LIFECYCLE_RET_OK;
}
Expand Down Expand Up @@ -84,13 +82,11 @@ class NegativeCallbackExceptionNode : public rclcpp_lifecycle::LifecycleNode
rcl_lifecycle_ret_t on_configure(const rclcpp_lifecycle::State &)
{
++number_of_callbacks;
throw std::runtime_error("On_configure exception");
throw std::runtime_error("custom exception raised in configure callback");
}

rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State & previous_state)
rcl_lifecycle_ret_t on_error(const rclcpp_lifecycle::State &)
{
fprintf(stderr, "Previous state of error was %s\n",
previous_state.label().c_str());
++number_of_callbacks;
return RCL_LIFECYCLE_RET_FAILURE;
}
Expand Down

0 comments on commit 436514a

Please sign in to comment.