nautilus_blockchain/rpc/
error.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3//  https://poseitrader.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;
17
18/// Represents errors that can occur when interacting with a blockchain RPC client.
19#[derive(Debug, Error)]
20pub enum BlockchainRpcClientError {
21    /// Occurs when the RPC client encounters a client-level error, such as connection failures.
22    #[error("Client error: {0}")]
23    ClientError(String),
24    /// Occurs when decoding contract ABI data fails.
25    #[error("Decoding error: {0}")]
26    AbiDecodingError(String),
27    /// Occurs when parsing an RPC message fails.
28    #[error("Parsing error: {0}")]
29    MessageParsingError(String),
30    /// Occurs when receiving an unsupported RPC response type.
31    #[error("Unsupported rpc response type of message {0}")]
32    UnsupportedRpcResponseType(String),
33    /// Occurs when an internal RPC client error is encountered.
34    #[error("Internal Rpc client error: {0}")]
35    InternalRpcClientError(String),
36    /// Indicates that no message was received from the RPC channel.
37    #[error("No message received")]
38    NoMessageReceived,
39}