use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecordError {
Reserved {
handle: String,
},
InvalidTime {
handle: String,
},
UnknownHandle {
handle: String,
},
TypeMismatch {
handle: String,
existing: String,
requested: String,
},
}
impl fmt::Display for RecordError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Reserved { handle } => write!(
f,
"ɴsɪ node {handle:?} is reserved: it exists already and \
cannot be created or deleted"
),
Self::InvalidTime { handle } => write!(
f,
"ɴsɪ motion sample on node {handle:?} has a time that is \
not a finite number"
),
Self::UnknownHandle { handle } => write!(
f,
"ɴsɪ connection names node {handle:?}, which does not \
exist; the nodes a connection is made on must be \
created first"
),
Self::TypeMismatch {
handle,
existing,
requested,
} => write!(
f,
"ɴsɪ node {handle:?} already exists as {existing:?}; \
re-creating it as {requested:?} is an error, not an \
overwrite"
),
}
}
}
impl core::error::Error for RecordError {}