From e60dd7c768d469a42c2d238327ba9a53ae6a30b3 Mon Sep 17 00:00:00 2001 From: clint Date: Sat, 2 Dec 2023 14:44:07 +0800 Subject: [PATCH] Fixed JSON-RPC error handle bug --- starknet-providers/src/jsonrpc/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/starknet-providers/src/jsonrpc/mod.rs b/starknet-providers/src/jsonrpc/mod.rs index d45a0f14..3ded1ef4 100644 --- a/starknet-providers/src/jsonrpc/mod.rs +++ b/starknet-providers/src/jsonrpc/mod.rs @@ -2,6 +2,7 @@ use std::{any::Any, error::Error}; use async_trait::async_trait; use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde_json::Value; use serde_with::serde_as; use starknet_core::{ serde::unsigned_field_element::UfeHex, @@ -151,6 +152,7 @@ pub enum RpcError { pub struct JsonRpcError { pub code: i64, pub message: String, + pub data: Option, } #[derive(Debug, Deserialize)] @@ -196,7 +198,7 @@ where Ok(code) => MaybeUnknownErrorCode::Known(code), Err(_) => MaybeUnknownErrorCode::Unknown(error.code), }, - message: error.message, + message: error.data.map_or(error.message, |data| data.to_string()), })) } }