rs_ach/
error.rs

1//! Error types for ACH file parsing.
2
3use thiserror::Error;
4
5/// Errors that can occur during ACH file parsing.
6#[derive(Error, Debug)]
7pub enum AchError {
8    /// The record type is invalid or unsupported.
9    #[error("Invalid record type: {0}")]
10    InvalidRecordType(String),
11
12    /// The line length does not match the expected 94 characters.
13    #[error("Invalid line length: expected 94, got {0}")]
14    InvalidLineLength(usize),
15
16    /// A numeric field could not be parsed.
17    #[error("Invalid numeric field '{field}': {source}")]
18    InvalidNumber {
19        field: &'static str,
20        source: std::num::ParseIntError,
21    },
22
23    /// The file structure is invalid (e.g., missing header or control records).
24    #[error("Invalid file structure: {0}")]
25    InvalidStructure(String),
26
27    /// The file is empty or contains no valid records.
28    #[error("Empty file")]
29    EmptyFile,
30
31    /// A batch is missing required records.
32    #[error("Incomplete batch: {0}")]
33    IncompleteBatch(String),
34}