1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum AmountError {
8 TooManyDecimals,
10 Overflow,
12}
13
14impl fmt::Display for AmountError {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 match self {
17 Self::TooManyDecimals => write!(f, "amount has more than two fraction digits"),
18 Self::Overflow => write!(f, "amount overflow"),
19 }
20 }
21}
22
23impl std::error::Error for AmountError {}
24
25#[derive(Debug, Clone, PartialEq, Eq)]
27pub enum DateError {
28 Invalid,
30}
31
32impl fmt::Display for DateError {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 write!(f, "not an EN 16931 calendar date (YYYY-MM-DD, no time)")
35 }
36}
37
38impl std::error::Error for DateError {}
39
40#[derive(Debug, Clone, PartialEq, Eq)]
42pub enum AttachmentError {
43 EmptyMime,
45 EmptyFilename,
47}
48
49impl fmt::Display for AttachmentError {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 match self {
52 Self::EmptyMime => write!(f, "attachment mime code shall be present"),
53 Self::EmptyFilename => write!(f, "attachment filename shall be present"),
54 }
55 }
56}
57
58impl std::error::Error for AttachmentError {}