Skip to content

Commit f48a590

Browse files
committed
Add rcl_action error codes
There's one error code, ActionNameInvalid, that conflicts with the EventInvalid code. We should consult with upstream about this, as it causes issues for representing error codes as enum values. These two error codes are probably never returned by the same function, but it would be better to keep them unique.
1 parent f6d11a7 commit f48a590

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

rclrs/src/error.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,26 @@ pub enum RclReturnCode {
201201
EventInvalid = 2000,
202202
/// Failed to take an event from the event handle
203203
EventTakeFailed = 2001,
204+
// ====== 2XXX: action-specific errors ======
205+
/// Action name does not pass validation
206+
// TODO(nwn): Consult with upstream about this reused error code.
207+
// ActionNameInvalid = 2000,
208+
/// Action goal accepted
209+
ActionGoalAccepted = 2100,
210+
/// Action goal rejected
211+
ActionGoalRejected = 2101,
212+
/// Action client is invalid
213+
ActionClientInvalid = 2102,
214+
/// Action client failed to take response
215+
ActionClientTakeFailed = 2103,
216+
/// Action server is invalid
217+
ActionServerInvalid = 2200,
218+
/// Action server failed to take request
219+
ActionServerTakeFailed = 2201,
220+
/// Action goal handle invalid
221+
ActionGoalHandleInvalid = 2300,
222+
/// Action invalid event
223+
ActionGoalEventInvalid = 2301,
204224
// ====== 30XX: lifecycle-specific errors ======
205225
/// `rcl_lifecycle` state registered
206226
LifecycleStateRegistered = 3000,
@@ -249,6 +269,15 @@ impl TryFrom<i32> for RclReturnCode {
249269
x if x == Self::InvalidLogLevelRule as i32 => Self::InvalidLogLevelRule,
250270
x if x == Self::EventInvalid as i32 => Self::EventInvalid,
251271
x if x == Self::EventTakeFailed as i32 => Self::EventTakeFailed,
272+
// x if x == Self::ActionNameInvalid as i32 => Self::ActionNameInvalid,
273+
x if x == Self::ActionGoalAccepted as i32 => Self::ActionGoalAccepted,
274+
x if x == Self::ActionGoalRejected as i32 => Self::ActionGoalRejected,
275+
x if x == Self::ActionClientInvalid as i32 => Self::ActionClientInvalid,
276+
x if x == Self::ActionClientTakeFailed as i32 => Self::ActionClientTakeFailed,
277+
x if x == Self::ActionServerInvalid as i32 => Self::ActionServerInvalid,
278+
x if x == Self::ActionServerTakeFailed as i32 => Self::ActionServerTakeFailed,
279+
x if x == Self::ActionGoalHandleInvalid as i32 => Self::ActionGoalHandleInvalid,
280+
x if x == Self::ActionGoalEventInvalid as i32 => Self::ActionGoalEventInvalid,
252281
x if x == Self::LifecycleStateRegistered as i32 => Self::LifecycleStateRegistered,
253282
x if x == Self::LifecycleStateNotRegistered as i32 => Self::LifecycleStateNotRegistered,
254283
other => {
@@ -330,6 +359,15 @@ impl Display for RclReturnCode {
330359
Self::EventTakeFailed => {
331360
"Failed to take an event from the event handle (RCL_RET_EVENT_TAKE_FAILED)."
332361
}
362+
// Self::ActionNameInvalid => "Action name does not pass validation (RCL_RET_ACTION_NAME_INVALID).",
363+
Self::ActionGoalAccepted => "Action goal accepted (RCL_RET_ACTION_GOAL_ACCEPTED).",
364+
Self::ActionGoalRejected => "Action goal rejected (RCL_RET_ACTION_GOAL_REJECTED).",
365+
Self::ActionClientInvalid => "Action client is invalid (RCL_RET_ACTION_CLIENT_INVALID).",
366+
Self::ActionClientTakeFailed => "Action client failed to take response (RCL_RET_ACTION_CLIENT_TAKE_FAILED).",
367+
Self::ActionServerInvalid => "Action server is invalid (RCL_RET_ACTION_SERVER_INVALID).",
368+
Self::ActionServerTakeFailed => "Action server failed to take request (RCL_RET_ACTION_SERVER_TAKE_FAILED).",
369+
Self::ActionGoalHandleInvalid => "Action goal handle invalid (RCL_RET_ACTION_GOAL_HANDLE_INVALID).",
370+
Self::ActionGoalEventInvalid => "Action invalid event (RCL_RET_ACTION_GOAL_EVENT_INVALID).",
333371
Self::LifecycleStateRegistered => {
334372
"`rcl_lifecycle` state registered (RCL_RET_LIFECYCLE_STATE_REGISTERED)."
335373
}

0 commit comments

Comments
 (0)