ethrex_rpc/clients/eth/
errors.rs1use crate::utils::RpcRequest;
2use ethrex_common::{FromStrRadixErr, types::transaction::GenericTransactionError};
3
4#[derive(Debug, thiserror::Error)]
6pub enum RpcRequestError {
7 #[error("{method}: {source}")]
8 SerdeJSONError {
9 method: String,
10 source: serde_json::Error,
11 },
12 #[error("{method}: {message} (data: {data:?})")]
13 RPCError {
14 method: String,
15 message: String,
16 data: Option<String>,
17 },
18 #[error("{method}: {source}")]
19 ParseIntError {
20 method: String,
21 source: std::num::ParseIntError,
22 },
23 #[error("{method}: {source}")]
24 HexError {
25 method: String,
26 source: hex::FromHexError,
27 },
28 #[error("{method}: {message}")]
29 RLPDecodeError { method: String, message: String },
30 #[error("{0}")]
31 Custom(String),
32}
33
34#[derive(Debug, thiserror::Error)]
35pub enum EthClientError {
36 #[error("Error sending request {0:?}")]
37 RequestError(RpcRequest),
38 #[error("reqwest error: {0}")]
39 ReqwestError(#[from] reqwest::Error),
40 #[error("RPC request error: {0}")]
41 RpcRequestError(#[from] RpcRequestError),
42 #[error("Failed to serialize request body: {0}")]
43 FailedToSerializeRequestBody(String),
44 #[error("Unreachable nonce")]
45 UnreachableNonce,
46 #[error("Error: {0}")]
47 Custom(String),
48 #[error("Failed to encode calldata: {0}")]
49 CalldataEncodeError(#[from] CalldataEncodeError),
50 #[error("Max number of retries reached when trying to send transaction")]
51 TimeoutError,
52 #[error("Internal Error. This is most likely a bug: {0}")]
53 InternalError(String),
54 #[error("Parse Url Error. {0}")]
55 ParseUrlError(String),
56 #[error("Failed to sign payload: {0}")]
57 FailedToSignPayload(String),
58 #[error("All RPC calls failed")]
59 FailedAllRPC,
60 #[error("Generic transaction error: {0}")]
61 GenericTransactionError(#[from] GenericTransactionError),
62 #[error("Failed to parse hex string: {0}")]
63 FromStrRadixError(#[from] FromStrRadixErr),
64}
65
66#[derive(Debug, thiserror::Error)]
67pub enum CalldataEncodeError {
68 #[error("Failed to parse function signature: {0}")]
69 ParseError(String),
70 #[error("Wrong number of arguments provided for calldata: {0}")]
71 WrongArgumentLength(String),
72 #[error("Internal Calldata encoding error. This is most likely a bug")]
73 InternalError,
74}