Skip to main content

ib_flex/
error.rs

1//! Error types for FLEX parsing
2
3use thiserror::Error;
4
5/// Result type alias for FLEX parsing operations
6pub type Result<T> = std::result::Result<T, ParseError>;
7
8/// Errors that can occur during FLEX XML parsing
9#[derive(Error, Debug)]
10pub enum ParseError {
11    /// XML deserialization error
12    #[error("XML deserialization error: {message}")]
13    XmlError {
14        /// Error message from XML parser
15        message: String,
16        /// Optional location in XML where error occurred
17        location: Option<String>,
18    },
19
20    /// Invalid date format
21    #[error("Invalid date format: {0}")]
22    InvalidDate(String),
23
24    /// Invalid decimal format
25    #[error("Invalid decimal format: {0}")]
26    InvalidDecimal(String),
27
28    /// Missing required field
29    #[error("Missing required field: {field} in {context}")]
30    MissingField {
31        /// Name of the missing field
32        field: String,
33        /// Context where field was expected
34        context: String,
35    },
36
37    /// Unknown enum variant
38    #[error("Unknown enum variant: {variant} for type {enum_type}")]
39    UnknownEnumVariant {
40        /// The unknown variant value
41        variant: String,
42        /// The enum type name
43        enum_type: String,
44    },
45
46    /// Unsupported FLEX schema version
47    #[error("Unsupported FLEX schema version: {0}")]
48    UnsupportedSchemaVersion(String),
49
50    /// IO error
51    #[error("IO error: {0}")]
52    Io(#[from] std::io::Error),
53}