nautilus_coinbase_intx/websocket/error.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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
16use thiserror::Error;
17use tokio_tungstenite::tungstenite;
18
19/// A typed error enumeration for the Coinbase WebSocket client.
20#[derive(Debug, Error)]
21pub enum CoinbaseIntxWsError {
22 #[error("Parsing error: {0}")]
23 ParsingError(String),
24 /// Errors returned directly by Coinbase (non-zero code).
25 #[error("Coinbase error {code}: {message}")]
26 CoinbaseError { code: String, message: String },
27 /// Failure during JSON serialization/deserialization.
28 #[error("JSON error: {0}")]
29 JsonError(String),
30 #[error("Client error: {0}")]
31 ClientError(String),
32 /// Wrapping the underlying HttpClientError from the network crate.
33 // #[error("Network error: {0}")]
34 // WebSocketClientError(WebSocketClientError), // TODO: Implement Debug
35 /// Any unknown HTTP status or unexpected response from Coinbase.
36 #[error("Tungstenite error: {0}")]
37 TungsteniteError(tungstenite::Error),
38}