Skip to main content

nautilus_polymarket/websocket/
error.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! WebSocket errors for Polymarket.
17
18use nautilus_network::error::SendError;
19use thiserror::Error;
20
21/// Errors for Polymarket WebSocket operations.
22#[derive(Debug, Clone, Error)]
23pub enum PolymarketWsError {
24    #[error("URL parsing failed: {0}")]
25    UrlParsing(String),
26
27    #[error("Message serialization failed: {0}")]
28    MessageSerialization(String),
29
30    #[error("Message deserialization failed: {0}")]
31    MessageDeserialization(String),
32
33    #[error("WebSocket connection failed: {0}")]
34    Connection(String),
35
36    #[error("Authentication failed: {0}")]
37    Authentication(String),
38
39    #[error("Channel send failed: {0}")]
40    ChannelSend(String),
41
42    #[error("Tungstenite error: {0}")]
43    TungsteniteError(String),
44
45    #[error("Client error: {0}")]
46    Client(String),
47
48    #[error("Network error: {0}")]
49    Network(String),
50
51    #[error("No active WebSocket client")]
52    NoActiveClient,
53
54    #[error("Handler not available: {0}")]
55    HandlerUnavailable(String),
56
57    #[error("WebSocket send error: {0}")]
58    TransportSend(#[from] SendError),
59
60    #[error("Operation timed out after {timeout_ms}ms")]
61    OperationTimeout { timeout_ms: u64 },
62}