Skip to content

Commit b75803a

Browse files
committed
added example to RclrsError
1 parent 38a6a92 commit b75803a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rclrs/src/error.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ 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:
14+
/// ```rust
15+
/// let error: RclrsError = RclrsError::RclError { code: RclReturnCode::Timeout, msg: None };
16+
/// match &error {
17+
/// RclrsError::RclError { msg, .. } => assert_eq!(msg, &None),
18+
/// _ => panic!("Unexpected error variant"),
19+
/// }
20+
/// ```
1321
RclError {
1422
/// The error code.
1523
code: RclReturnCode,

0 commit comments

Comments
 (0)