Skip to content

Commit adba623

Browse files
author
GueLaKais
committed
added rudimentary display implementation
1 parent 2b19fe3 commit adba623

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

rclrs/src/parameter.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,34 @@ pub enum DeclarationError {
643643
/// An invalid range was provided to a parameter declaration (i.e. lower bound > higher bound).
644644
InvalidRange,
645645
}
646+
impl Display for DeclarationError {
647+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
648+
match self {
649+
DeclarationError::AlreadyDeclared => write!(
650+
f,
651+
"Parameter was already declared and a new declaration was attempted"
652+
),
653+
DeclarationError::NoValueAvailable => write!(
654+
f,
655+
"Parameter was declared as non optional but no value was available"
656+
),
657+
DeclarationError::OverrideValueTypeMismatch => {
658+
write!(f, "The override value that was provided has the wrong type")
659+
}
660+
DeclarationError::PriorValueTypeMismatch => write!(
661+
f,
662+
"The value that the parameter was already set to has the wrong type"
663+
),
664+
DeclarationError::InitialValueOutOfRange => {
665+
write!(f, "The initial value that was selected is out of range")
666+
}
667+
DeclarationError::InvalidRange => write!(
668+
f,
669+
"An invalid range was provided to a parameter declaration"
670+
),
671+
}
672+
}
673+
}
646674

647675
impl<'a> Parameters<'a> {
648676
/// Tries to read a parameter of the requested type.

0 commit comments

Comments
 (0)