Skip to content

Commit 0325921

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 453c208 commit 0325921

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
@@ -174,6 +174,26 @@ pub enum RclReturnCode {
174174
EventInvalid = 2000,
175175
/// Failed to take an event from the event handle
176176
EventTakeFailed = 2001,
177+
// ====== 2XXX: action-specific errors ======
178+
/// Action name does not pass validation
179+
// TODO(nwn): Consult with upstream about this reused error code.
180+
// ActionNameInvalid = 2000,
181+
/// Action goal accepted
182+
ActionGoalAccepted = 2100,
183+
/// Action goal rejected
184+
ActionGoalRejected = 2101,
185+
/// Action client is invalid
186+
ActionClientInvalid = 2102,
187+
/// Action client failed to take response
188+
ActionClientTakeFailed = 2103,
189+
/// Action server is invalid
190+
ActionServerInvalid = 2200,
191+
/// Action server failed to take request
192+
ActionServerTakeFailed = 2201,
193+
/// Action goal handle invalid
194+
ActionGoalHandleInvalid = 2300,
195+
/// Action invalid event
196+
ActionGoalEventInvalid = 2301,
177197
// ====== 30XX: lifecycle-specific errors ======
178198
/// `rcl_lifecycle` state registered
179199
LifecycleStateRegistered = 3000,
@@ -222,6 +242,15 @@ impl TryFrom<i32> for RclReturnCode {
222242
x if x == Self::InvalidLogLevelRule as i32 => Self::InvalidLogLevelRule,
223243
x if x == Self::EventInvalid as i32 => Self::EventInvalid,
224244
x if x == Self::EventTakeFailed as i32 => Self::EventTakeFailed,
245+
// x if x == Self::ActionNameInvalid as i32 => Self::ActionNameInvalid,
246+
x if x == Self::ActionGoalAccepted as i32 => Self::ActionGoalAccepted,
247+
x if x == Self::ActionGoalRejected as i32 => Self::ActionGoalRejected,
248+
x if x == Self::ActionClientInvalid as i32 => Self::ActionClientInvalid,
249+
x if x == Self::ActionClientTakeFailed as i32 => Self::ActionClientTakeFailed,
250+
x if x == Self::ActionServerInvalid as i32 => Self::ActionServerInvalid,
251+
x if x == Self::ActionServerTakeFailed as i32 => Self::ActionServerTakeFailed,
252+
x if x == Self::ActionGoalHandleInvalid as i32 => Self::ActionGoalHandleInvalid,
253+
x if x == Self::ActionGoalEventInvalid as i32 => Self::ActionGoalEventInvalid,
225254
x if x == Self::LifecycleStateRegistered as i32 => Self::LifecycleStateRegistered,
226255
x if x == Self::LifecycleStateNotRegistered as i32 => Self::LifecycleStateNotRegistered,
227256
other => {
@@ -303,6 +332,15 @@ impl Display for RclReturnCode {
303332
Self::EventTakeFailed => {
304333
"Failed to take an event from the event handle (RCL_RET_EVENT_TAKE_FAILED)."
305334
}
335+
// Self::ActionNameInvalid => "Action name does not pass validation (RCL_RET_ACTION_NAME_INVALID).",
336+
Self::ActionGoalAccepted => "Action goal accepted (RCL_RET_ACTION_GOAL_ACCEPTED).",
337+
Self::ActionGoalRejected => "Action goal rejected (RCL_RET_ACTION_GOAL_REJECTED).",
338+
Self::ActionClientInvalid => "Action client is invalid (RCL_RET_ACTION_CLIENT_INVALID).",
339+
Self::ActionClientTakeFailed => "Action client failed to take response (RCL_RET_ACTION_CLIENT_TAKE_FAILED).",
340+
Self::ActionServerInvalid => "Action server is invalid (RCL_RET_ACTION_SERVER_INVALID).",
341+
Self::ActionServerTakeFailed => "Action server failed to take request (RCL_RET_ACTION_SERVER_TAKE_FAILED).",
342+
Self::ActionGoalHandleInvalid => "Action goal handle invalid (RCL_RET_ACTION_GOAL_HANDLE_INVALID).",
343+
Self::ActionGoalEventInvalid => "Action invalid event (RCL_RET_ACTION_GOAL_EVENT_INVALID).",
306344
Self::LifecycleStateRegistered => {
307345
"`rcl_lifecycle` state registered (RCL_RET_LIFECYCLE_STATE_REGISTERED)."
308346
}

0 commit comments

Comments
 (0)