1use core::fmt;
2
3#[non_exhaustive]
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum HeaderError {
7 Missing,
9 MalformedProcessingInstruction { detail: String },
11 MissingAttribute { attribute: &'static str },
13 InvalidVersion { value: String },
15 InvalidSecurity { value: String },
17}
18
19impl fmt::Display for HeaderError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Self::Missing => f.write_str("no OFX header found"),
23 Self::MalformedProcessingInstruction { detail } => {
24 write!(f, "malformed OFX processing instruction: {detail}")
25 }
26 Self::MissingAttribute { attribute } => {
27 write!(f, "missing required OFX header attribute: {attribute}")
28 }
29 Self::InvalidVersion { value } => {
30 write!(f, "invalid OFX version in header: '{value}'")
31 }
32 Self::InvalidSecurity { value } => {
33 write!(f, "invalid OFX security level in header: '{value}'")
34 }
35 }
36 }
37}
38
39impl std::error::Error for HeaderError {}