detail of InvalidParams is changed

This commit is contained in:
병준 박 2022-08-05 03:47:43 +00:00
parent e2136514b5
commit a3afe66b5d
2 changed files with 5 additions and 17 deletions

View File

@ -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]

View File

@ -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<InvalidParamsDetail>,
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<InvalidParams> 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<Error> 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,