iso_4217/error.rs
1use std::fmt;
2
3/// An error which can be returned when parsing `&str` or `u32`.
4#[derive(Debug, PartialEq, Clone)]
5pub enum ParseCodeError {
6 Alpha(String),
7 Num(u32),
8}
9
10impl fmt::Display for ParseCodeError {
11 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12 use ParseCodeError::*;
13 match self {
14 Alpha(v) => write!(f, "`{}` is no match any alphabetic code.", v),
15 Num(v) => write!(f, "{} is no match numeric code.", v),
16 }
17 }
18}
19
20impl std::error::Error for ParseCodeError {}