Skip to content

Commit 7ed5702

Browse files
committed
added example to RclrsError
1 parent cf64a41 commit 7ed5702

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rclrs/src/error.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ use std::{
44
fmt::{self, Display},
55
};
66

7-
use crate::{rcl_bindings::*, DeclarationError};
7+
use crate::{DeclarationError, rcl_bindings::*};
88

99
/// The main error type.
1010
#[derive(Debug, PartialEq, Eq)]
1111
pub enum RclrsError {
1212
/// An error originating in the `rcl` layer.
13+
/// Example: /// ```rust
14+
/// let error: RclrsError = RclrsError::RclError { code: RclReturnCode::Timeout, msg: None };
15+
/// match &error {
16+
/// RclrsError::RclError { msg, .. } => assert_eq!(msg, &None),
17+
/// _ => panic!("Unexpected error variant"),
18+
/// }
19+
/// ```
1320
RclError {
1421
/// The error code.
1522
code: RclReturnCode,

0 commit comments

Comments
 (0)