From a3afe66b5d8eae4fee1446199a9928cd98a74abc Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Fri, 5 Aug 2022 03:47:43 +0000 Subject: [PATCH] detail of InvalidParams is changed --- Cargo.toml | 2 +- src/error/rpc.rs | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a18e217..a7523ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ serde = { version = "1", features = ["derive"] } serde_json = { version = "1" } prost = { version = "0" } -beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.20-snapshot" } +beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.21-snapshot" } [build-dependencies] diff --git a/src/error/rpc.rs b/src/error/rpc.rs index 249a1d5..b8bca06 100644 --- a/src/error/rpc.rs +++ b/src/error/rpc.rs @@ -168,31 +168,19 @@ impl From<&InvalidParamsDetail> for bpr::protobuf::rpc::InvalidParamsDetail { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct InvalidParams { pub message: String, - pub details: Vec, + pub detail: InvalidParamsDetail, } impl fmt::Display for InvalidParams { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, - "Invalid Params error, message: {}, details: {:?}", - self.message, self.details + "Invalid Params error, message: {}, detail: {:?}", + self.message, self.detail ) } } -impl From for bpr::protobuf::rpc::InvalidParams { - fn from(p: InvalidParams) -> Self { - bpr::protobuf::rpc::InvalidParams { - details: p - .details - .iter() - .map(bpr::protobuf::rpc::InvalidParamsDetail::from) - .collect(), - } - } -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Internal { pub message: String, @@ -270,7 +258,7 @@ impl From for bpr::protobuf::rpc::Error { Error::InvalidParams(e) => bpr::protobuf::rpc::Error { code: -32602, message: e.message.clone(), - data: Some(bpr::protobuf::rpc::InvalidParams::from(e).encode_to_vec()), + data: Some(bpr::protobuf::rpc::InvalidParamsDetail::from(&e.detail).encode_to_vec()), }, Error::Internal(e) => bpr::protobuf::rpc::Error { code: -32603,