pub struct Notice {
pub code: i32,
pub message: String,
pub error_time: Option<OffsetDateTime>,
pub advanced_order_reject_json: String,
}Expand description
An error message from the TWS API.
Fields§
§code: i32Error code reported by TWS.
message: StringHuman-readable error message text.
error_time: Option<OffsetDateTime>Timestamp when the error occurred. Only present for server versions >= ERROR_TIME (194).
advanced_order_reject_json: StringAdvanced order-reject JSON payload, present on hard order-rejection notices for server versions >= ADVANCED_ORDER_REJECT. Empty otherwise.
Implementations§
Source§impl Notice
impl Notice
Sourcepub fn is_cancellation(&self) -> bool
pub fn is_cancellation(&self) -> bool
Returns true if this notice indicates an order was cancelled (code 202).
Code 202 is sent by TWS to confirm an order cancellation. This is an informational message, not an error.
Sourcepub fn is_warning(&self) -> bool
pub fn is_warning(&self) -> bool
Returns true if this is a warning message (codes 2100-2169).
Sourcepub fn is_system_message(&self) -> bool
pub fn is_system_message(&self) -> bool
Returns true if this is a system/connectivity message (codes 1100-1102, 1300).
System messages indicate connectivity status changes:
- 1100: Connectivity between IB and TWS lost
- 1101: Connectivity restored, market data lost (resubscribe needed)
- 1102: Connectivity restored, market data maintained
- 1300: Socket port reset during active connection
Sourcepub fn is_data_advisory(&self) -> bool
pub fn is_data_advisory(&self) -> bool
Returns true if this is a data advisory (DATA_ADVISORY_CODES).
Data advisories (codes 10089, 10167) announce that a request proceeded with a fallback — delayed market data instead of real-time — rather than failing. The requested data still follows, so the subscription stays open and the notice is informational, not an error.
Sourcepub fn is_informational(&self) -> bool
pub fn is_informational(&self) -> bool
Returns true if this is an informational notice (not an error).
Informational notices include cancellation confirmations, warnings, system/connectivity messages, and data advisories.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Returns true if this is an error requiring attention.
Returns false for informational messages like cancellation confirmations,
warnings, and system messages.
Sourcepub fn is_order_rejection(&self) -> bool
pub fn is_order_rejection(&self) -> bool
Returns true if this notice falls in the order-rejection range (200-399).
Code 202 (cancellation confirmation) is numerically inside this range; this
predicate returns true for it. For a disjoint partition that routes 202
to NoticeCategory::Cancellation instead, use Notice::category.
§Examples
use ibapi::Notice;
if notice.is_order_rejection() {
eprintln!("rejection: {}", notice);
}Sourcepub fn is_handshake_synthetic(&self) -> bool
pub fn is_handshake_synthetic(&self) -> bool
Returns true if this notice was synthesized client-side during the
connection handshake — i.e. carries either
HANDSHAKE_UNKNOWN_FRAME_CODE (an IncomingMessages kind with no
typed StartupMessage variant) or HANDSHAKE_DECODE_FAILURE_CODE
(a typed decoder failed on a known kind).
Subscribers to Client::notice_stream
can use this to log + investigate without conflating with TWS-emitted
notices.
§Examples
use ibapi::Notice;
if notice.is_handshake_synthetic() {
eprintln!("handshake observability: code={} {}", notice.code, notice);
}Sourcepub fn category(&self) -> NoticeCategory
pub fn category(&self) -> NoticeCategory
Classify this notice into a disjoint NoticeCategory.
See NoticeCategory for the precedence chain.
§Examples
use ibapi::{Notice, NoticeCategory};
let level = match notice.category() {
NoticeCategory::Cancellation
| NoticeCategory::Warning
| NoticeCategory::SystemMessage => "info",
NoticeCategory::OrderRejection | NoticeCategory::Error => "error",
_ => "unknown",
};Sourcepub fn connectivity_status(&self) -> Option<ConnectivityStatus>
pub fn connectivity_status(&self) -> Option<ConnectivityStatus>
Classify the data-farm connectivity sub-state of this notice.
Returns Some(..) for the data-farm status codes inside
WARNING_CODE_RANGE; None for every other notice. Additive to
Notice::category, which still classifies all of 2100..=2169 as
NoticeCategory::Warning. Thin wrapper over
ConnectivityStatus::from_code.
§Examples
use ibapi::{Notice, ConnectivityStatus};
if notice.connectivity_status() == Some(ConnectivityStatus::Broken) {
eprintln!("data farm down: {notice}");
}