1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::num::ParseIntError;

use thiserror::Error;

#[derive(Error, Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum ShebaValidationError {
    #[error("empty")]
    Empty,

    #[error("not started with IR")]
    NotStartedWithIR,

    #[error("invalid digit")]
    InvalidDigit,

    #[error("invalid length: {0:?}")]
    InvalidLength(usize),

    #[error("invalid checksum")]
    InvalidChecksum,

    #[error("bank not found")]
    BankNotFound,

    #[error("you should not see this! please make a issue on our github")]
    InternalError,
}

impl From<ParseIntError> for ShebaValidationError {
    fn from(_: ParseIntError) -> Self {
        ShebaValidationError::InvalidDigit
    }
}