#![warn(missing_docs)]
use std::error::Error;
use std::fmt::Formatter;
use std::fmt::{Debug, Display};
#[non_exhaustive]
#[derive(Clone, PartialEq, Eq)]
pub enum CIKError {
InvalidLength {
was: usize,
},
InvalidFormat {
was: String,
},
InvalidValue {
was: u64,
},
}
impl Debug for CIKError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
CIKError::InvalidLength { was } => {
write!(f, "InvalidLength {{ was: {:?} }}", was)
}
CIKError::InvalidFormat { was } => {
write!(f, "InvalidFormat {{ was: {:?} }}", was)
}
CIKError::InvalidValue { was } => {
write!(f, "InvalidValue {{ was: {:?} }}", was)
}
}
}
}
impl Display for CIKError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
CIKError::InvalidLength { was } => {
write!(f, "invalid length {} bytes when expecting 1 to 10", was)
}
CIKError::InvalidFormat { was } => {
write!(f, "invalid format {} when expecting integer", was)
}
CIKError::InvalidValue { was } => {
write!(
f,
"invalid value {} when expecting positive number up to 9,999,999,999",
was
)
}
}
}
}
impl Error for CIKError {}