Skip to main content

mt5_rs/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Mt5Error {
5    #[error("IO error: {0}")]
6    IoError(#[from] std::io::Error),
7
8    #[error("Connection failed: {0}")]
9    ConnectionFailed(String),
10
11    #[error("Protocol error: {0}")]
12    ProtocolError(String),
13
14    #[error("Invalid response: {0}")]
15    InvalidResponse(String),
16
17    #[error("MT5 not initialized")]
18    NotInitialized,
19
20    #[error("Command failed: cmd={cmd}, error={error}")]
21    CommandFailed { cmd: u32, error: String },
22
23    #[error("Not supported: {0}")]
24    NotSupported(String),
25}
26
27pub type Result<T> = std::result::Result<T, Mt5Error>;