Skip to main content

mx20022_translate/mt/
error.rs

1//! Error types for SWIFT MT message parsing.
2
3use thiserror::Error;
4
5/// Errors that can occur when parsing SWIFT MT messages.
6#[derive(Debug, Error)]
7pub enum MtError {
8    /// The top-level block structure is malformed (e.g., unmatched braces).
9    #[error("invalid block structure: {0}")]
10    InvalidBlockStructure(String),
11
12    /// The content of a specific block cannot be parsed.
13    #[error("invalid block {block} content: {detail}")]
14    InvalidBlockContent { block: u8, detail: String },
15
16    /// A required block is absent from the message.
17    #[error("missing required block: {0}")]
18    MissingBlock(u8),
19
20    /// A required field is missing from the message body.
21    #[error("missing required field: {tag} in MT{message_type}")]
22    MissingField { tag: String, message_type: String },
23
24    /// A field's value cannot be interpreted according to the SWIFT spec.
25    #[error("invalid field value for {tag}: {detail}")]
26    InvalidFieldValue { tag: String, detail: String },
27}