Skip to content

Commit

Permalink
Fixed JSON-RPC error handle bug
Browse files Browse the repository at this point in the history
  • Loading branch information
clint committed Dec 2, 2023
1 parent 64ebc36 commit e60dd7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion starknet-providers/src/jsonrpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -151,6 +152,7 @@ pub enum RpcError {
pub struct JsonRpcError {
pub code: i64,
pub message: String,
pub data: Option<Value>,
}

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -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()),
}))
}
}
Expand Down

0 comments on commit e60dd7c

Please sign in to comment.