server error is changed
This commit is contained in:
parent
a3afe66b5d
commit
b0fd020d6f
|
@ -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.21-snapshot" }
|
||||
beteran-protobuf-rust = { git = "https://gitlab.loafle.net/bet/beteran-protobuf-rust.git", tag = "v0.1.22-snapshot" }
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -194,7 +194,9 @@ impl fmt::Display for Internal {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Server {
|
||||
pub code: i32,
|
||||
pub message: String,
|
||||
pub data: Option<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl fmt::Display for Server {
|
||||
|
@ -246,29 +248,29 @@ impl From<Error> for bpr::protobuf::rpc::Error {
|
|||
fn from(err: Error) -> Self {
|
||||
match err {
|
||||
Error::Parse(e) => bpr::protobuf::rpc::Error {
|
||||
code: -32700,
|
||||
code: bpr::protobuf::rpc::Error::PARSE,
|
||||
message: e.message,
|
||||
data: None,
|
||||
},
|
||||
Error::InvalidRequest(e) => bpr::protobuf::rpc::Error {
|
||||
code: -32600,
|
||||
code: bpr::protobuf::rpc::Error::INVALID_REQUEST,
|
||||
message: e.message,
|
||||
data: None,
|
||||
},
|
||||
Error::InvalidParams(e) => bpr::protobuf::rpc::Error {
|
||||
code: -32602,
|
||||
code: bpr::protobuf::rpc::Error::INVALID_PARAMS,
|
||||
message: e.message.clone(),
|
||||
data: Some(bpr::protobuf::rpc::InvalidParamsDetail::from(&e.detail).encode_to_vec()),
|
||||
},
|
||||
Error::Internal(e) => bpr::protobuf::rpc::Error {
|
||||
code: -32603,
|
||||
code: bpr::protobuf::rpc::Error::INTERNAL,
|
||||
message: e.message,
|
||||
data: None,
|
||||
},
|
||||
Error::Server(e) => bpr::protobuf::rpc::Error {
|
||||
code: -32603,
|
||||
code: e.code,
|
||||
message: e.message,
|
||||
data: None,
|
||||
data: e.data,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user