use crate::ConstString;
#[non_exhaustive]
pub enum Error {
AlreadyInPortList {
key: ConstString,
},
CouldNotConvert {
value: ConstString,
port: ConstString,
},
Databoard {
source: databoard::Error,
},
NameNotAllowed {
port: ConstString,
},
NotFound {
key: ConstString,
},
}
impl core::error::Error for Error {
}
impl core::fmt::Debug for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::AlreadyInPortList { key } => write!(f, "AlreadyInPortList(key: {key})"),
Self::CouldNotConvert { value, port } => write!(f, "CouldNotConvert(value: {value}, value: {port})"),
Self::Databoard { source } => write!(f, "Databoard({source})"),
Self::NameNotAllowed { port } => write!(f, "NameNotAllowed(port: {port})"),
Self::NotFound { key } => write!(f, "NotFound(key: {key})"),
}
}
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::AlreadyInPortList { key } => write!(f, "the port {key} is already in the list of defined ports"),
Self::CouldNotConvert { value, port } => write!(f, "could not convert '{value}' into wanted type for {port}"),
Self::Databoard { source } => write!(f, "accessing blackboard failed with: {source}"),
Self::NameNotAllowed { port } => write!(f, "the name {port} is not allowed for a port"),
Self::NotFound { key } => write!(f, "key {key} could not be found"),
}
}
}
impl From<databoard::Error> for Error {
fn from(source: databoard::Error) -> Self {
Self::Databoard { source }
}
}