rpc_router/rpc_response/
rpc_response_parsing_error.rs1use crate::RpcId;
2use serde::Serialize;
3use serde_json::Value;
4use serde_with::{serde_as, DisplayFromStr};
5
6#[serde_as]
8#[derive(Debug, Serialize)]
9pub enum RpcResponseParsingError {
10 InvalidJsonRpcVersion {
11 id: Option<RpcId>,
12 expected: &'static str,
13 actual: Option<Value>,
14 },
15 MissingJsonRpcVersion {
16 id: Option<RpcId>,
17 },
18 MissingId,
19 InvalidId(#[serde_as(as = "DisplayFromStr")] crate::RpcRequestParsingError),
20 MissingResultAndError {
21 id: RpcId,
22 },
23 BothResultAndError {
24 id: RpcId,
25 },
26 InvalidErrorObject(#[serde_as(as = "DisplayFromStr")] serde_json::Error),
27 Serde(#[serde_as(as = "DisplayFromStr")] serde_json::Error),
28}
29
30impl core::fmt::Display for RpcResponseParsingError {
33 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error> {
34 write!(fmt, "{self:?}")
35 }
36}
37
38impl std::error::Error for RpcResponseParsingError {}
39
40impl From<serde_json::Error> for RpcResponseParsingError {
45 fn from(e: serde_json::Error) -> Self {
46 RpcResponseParsingError::Serde(e)
47 }
48}
49
50impl From<crate::RpcRequestParsingError> for RpcResponseParsingError {
51 fn from(e: crate::RpcRequestParsingError) -> Self {
52 RpcResponseParsingError::InvalidId(e)
53 }
54}
55
56