Skip to content

Commit 3360c94

Browse files
authored
Reset error state when converting to RclReturnCode (#162)
1 parent 5466525 commit 3360c94

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rclrs/src/error.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,11 @@ impl Error for RclReturnCode {}
592592
pub(crate) fn to_rcl_result(code: i32) -> Result<(), RclReturnCode> {
593593
match RclReturnCode::from(code) {
594594
RclReturnCode::Ok => Ok(()),
595-
anything_else => Err(anything_else),
595+
anything_else => {
596+
// SAFETY: No preconditions for this function.
597+
unsafe { rcutils_reset_error() };
598+
Err(anything_else)
599+
}
596600
}
597601
}
598602

0 commit comments

Comments
 (0)