Skip to main content

ironfix_engine/
error.rs

1/******************************************************************************
2   Author: Joaquín Béjar García
3   Email: jb@taunais.com
4   Date: 14/7/26
5******************************************************************************/
6
7//! Engine error types.
8
9use ironfix_core::error::DecodeError;
10use ironfix_transport::CodecError;
11use std::time::Duration;
12
13/// Errors produced by the engine transport layer.
14#[derive(Debug, thiserror::Error)]
15pub enum EngineError {
16    /// Underlying I/O failure.
17    #[error("io error: {0}")]
18    Io(#[from] std::io::Error),
19
20    /// Framing or checksum failure at the codec layer.
21    #[error("codec error: {0}")]
22    Codec(#[from] CodecError),
23
24    /// Failure decoding a framed FIX message.
25    #[error("decode error: {0}")]
26    Decode(#[from] DecodeError),
27
28    /// TCP connect did not complete within the configured timeout.
29    #[error("connect timed out after {0:?}")]
30    ConnectTimeout(Duration),
31
32    /// The Logon acknowledgement did not arrive within the logon timeout.
33    #[error("logon timed out after {0:?}")]
34    LogonTimeout(Duration),
35
36    /// The counterparty rejected the Logon.
37    #[error("logon rejected: {reason}")]
38    LogonRejected {
39        /// Text supplied by the counterparty, or a generic description.
40        reason: String,
41    },
42
43    /// An unexpected message type arrived while awaiting the Logon
44    /// acknowledgement.
45    #[error("unexpected message during logon: 35={msg_type}")]
46    UnexpectedMessage {
47        /// The received MsgType (tag 35) value.
48        msg_type: String,
49    },
50
51    /// A sequence number violation that is fatal for the session.
52    #[error("sequence error: {0}")]
53    Sequence(String),
54
55    /// The connection is closed; no more messages can be sent.
56    #[error("connection closed")]
57    Closed,
58}