Skip to main content

fints/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during FinTS operations.
4#[derive(Error, Debug)]
5pub enum FinTSError {
6    #[error("Parse error: {0}")]
7    Parse(String),
8
9    #[error("Serialization error: {0}")]
10    Serialize(String),
11
12    #[error("Transport error: {0}")]
13    Transport(String),
14
15    #[error("HTTP error (status {status}): {message}")]
16    Http { status: u16, message: String },
17
18    #[error("Dialog error: {0}")]
19    Dialog(String),
20
21    #[error("Authentication error: {0}")]
22    Auth(String),
23
24    #[error("TAN required but no TAN handler provided")]
25    TanRequired,
26
27    #[error("TAN rejected by bank: {0}")]
28    TanRejected(String),
29
30    #[error("TAN timeout: user did not confirm within the allowed time")]
31    TanTimeout,
32
33    #[error("Bank error ({kind:?}): {message}")]
34    BankError {
35        kind: crate::types::ResponseCodeKind,
36        message: String,
37    },
38
39    #[error("Segment not supported by bank: {0}")]
40    SegmentNotSupported(String),
41
42    #[error("Invalid response from bank: {0}")]
43    InvalidResponse(String),
44
45    #[error("MT940 parse error: {0}")]
46    Mt940(String),
47
48    #[error("PIN wrong")]
49    PinWrong,
50
51    #[error("Account locked")]
52    AccountLocked,
53
54    #[error("IO error: {0}")]
55    Io(#[from] std::io::Error),
56
57    #[error("Request error: {0}")]
58    Reqwest(#[from] reqwest::Error),
59}
60
61pub type Result<T> = std::result::Result<T, FinTSError>;