ankurah_proto/
error.rs

1#[derive(Debug)]
2pub enum DecodeError {
3    NotStringValue,
4    InvalidBase64(base64::DecodeError),
5    InvalidLength,
6    InvalidUlid,
7    InvalidFallback,
8    InvalidFormat,
9    Other(anyhow::Error),
10}
11
12impl std::fmt::Display for DecodeError {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        match self {
15            DecodeError::NotStringValue => write!(f, "Not a string value"),
16            DecodeError::InvalidBase64(e) => write!(f, "Invalid Base64: {}", e),
17            DecodeError::InvalidLength => write!(f, "Invalid Length"),
18            DecodeError::InvalidUlid => write!(f, "Invalid ULID"),
19            DecodeError::InvalidFallback => write!(f, "Invalid Fallback"),
20            DecodeError::Other(e) => write!(f, "Other: {}", e),
21            DecodeError::InvalidFormat => write!(f, "Invalid Format"),
22        }
23    }
24}
25
26impl std::error::Error for DecodeError {}
27
28impl From<base64::DecodeError> for DecodeError {
29    fn from(e: base64::DecodeError) -> Self { DecodeError::InvalidBase64(e) }
30}