1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::fmt::{Display, Formatter};

#[derive(Debug)]
pub enum DecodeError {
    InvalidCharacter(char),
    InvalidLength,
    NoSeparator,
}

impl Display for DecodeError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            DecodeError::InvalidCharacter(c) => write!(f, "Invalid character: {}", c),
            DecodeError::InvalidLength => write!(f, "Invalid length"),
            DecodeError::NoSeparator => write!(f, "No separator"),
        }
    }
}

impl std::error::Error for DecodeError {}