Skip to content

Commit

Permalink
convert throw_from_rcl_error to use from_rcl_error
Browse files Browse the repository at this point in the history
Mostly just a convenience function
Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>
  • Loading branch information
Jacob Hassold committed Apr 15, 2019
1 parent 451161f commit 2e9d12b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.DS_Store

*.swp

tags
tags
30 changes: 5 additions & 25 deletions rclcpp/src/rclcpp/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,11 @@ throw_from_rcl_error(
const rcl_error_state_t * error_state,
void (* reset_error)())
{
if (RCL_RET_OK == ret) {
throw std::invalid_argument("ret is RCL_RET_OK");
}
if (!error_state) {
error_state = rcl_get_error_state();
}
if (!error_state) {
throw std::runtime_error("rcl error state is not set");
}
std::string formated_prefix = prefix;
if (!prefix.empty()) {
formated_prefix += ": ";
}
RCLErrorBase base_exc(ret, error_state);
if (reset_error) {
reset_error();
}
switch (ret) {
case RCL_RET_BAD_ALLOC:
throw RCLBadAlloc(base_exc);
case RCL_RET_INVALID_ARGUMENT:
throw RCLInvalidArgument(base_exc, formated_prefix);
default:
throw RCLError(base_exc, formated_prefix);
}
// We expect this to either throw a standard error,
// or to generate an error pointer (which is caught
// in err, and immediately thrown)
auto err = from_rcl_error(rt, prefix, error_state, reset_error);
std::rethrow_exception(err);
}

std::exception_ptr
Expand Down

0 comments on commit 2e9d12b

Please sign in to comment.