truefix_twsapi_client/
error.rs1use thiserror::Error;
2
3pub type TwsApiResult<T> = Result<T, TwsApiError>;
5
6#[derive(Debug, Error)]
8pub enum TwsApiError {
9 #[error("TWS API fields must be printable ASCII: {0:?}")]
11 NonPrintableAscii(String),
12 #[error("cannot encode a missing TWS API field")]
14 MissingField,
15 #[error("TWS API frame length {0} is too large for this platform")]
17 FrameTooLarge(u32),
18 #[error("incomplete TWS API frame: need {needed} bytes, have {available} bytes")]
20 IncompleteFrame {
21 needed: usize,
23 available: usize,
25 },
26 #[error("malformed TWS API handshake response")]
28 MalformedHandshake,
29 #[error("TWS/Gateway server version {server_version} is below required minimum {min_version}")]
31 UnsupportedServerVersion {
32 server_version: i32,
34 min_version: i32,
36 },
37 #[error(
39 "TWS/Gateway server version {server_version} is below required minimum {min_version} for {parameter}"
40 )]
41 UnsupportedRequestParameter {
42 server_version: i32,
44 min_version: i32,
46 parameter: &'static str,
48 },
49 #[error("TWS API I/O error: {0}")]
51 Io(#[from] std::io::Error),
52 #[error("invalid TWS API integer field {field:?}: {source}")]
54 InvalidInteger {
55 field: String,
57 source: std::num::ParseIntError,
59 },
60 #[error("invalid TWS API decimal field {field:?}: {source}")]
62 InvalidDecimal {
63 field: String,
65 source: rust_decimal::Error,
67 },
68 #[error("invalid TWS API protobuf payload: {0}")]
70 ProtobufDecode(#[from] prost::DecodeError),
71}