1pub mod helpers;
4pub mod reader;
5
6use core::fmt;
7
8pub use reader::OfxReader;
9
10#[non_exhaustive]
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub enum XmlError {
14 MalformedXml { message: String },
16 UnexpectedElement { expected: String, found: String },
18 MissingElement { parent: String, element: String },
20 InvalidContent {
22 element: String,
23 value: String,
24 reason: String,
25 },
26}
27
28impl fmt::Display for XmlError {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Self::MalformedXml { message } => {
32 write!(f, "malformed XML: {message}")
33 }
34 Self::UnexpectedElement { expected, found } => {
35 write!(f, "expected element <{expected}>, found <{found}>")
36 }
37 Self::MissingElement { parent, element } => {
38 write!(f, "missing required element <{element}> in <{parent}>")
39 }
40 Self::InvalidContent {
41 element,
42 value,
43 reason,
44 } => {
45 write!(
46 f,
47 "invalid content in <{element}>: '{value}' ({reason})"
48 )
49 }
50 }
51 }
52}
53
54impl std::error::Error for XmlError {}