From e5f4b3c8c20d7c89d6e9da47c7541cfd93e2b11d Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Wed, 3 Aug 2022 06:19:47 +0000 Subject: [PATCH] display trait is added --- src/protobuf/rpc.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/protobuf/rpc.rs b/src/protobuf/rpc.rs index 04dcb2f..2150e09 100644 --- a/src/protobuf/rpc.rs +++ b/src/protobuf/rpc.rs @@ -1,9 +1,20 @@ +use std::fmt; #[derive(Clone, PartialEq, ::prost::Message)] pub struct Error { - #[prost(int32, tag="1")] - pub code: i32, - #[prost(string, optional, tag="2")] - pub message: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bytes="vec", optional, tag="3")] - pub data: ::core::option::Option<::prost::alloc::vec::Vec>, + #[prost(int32, tag = "1")] + pub code: i32, + #[prost(string, optional, tag = "2")] + pub message: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bytes = "vec", optional, tag = "3")] + pub data: ::core::option::Option<::prost::alloc::vec::Vec>, +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "Error code: {}, message: {:?}, data: {:?}", + self.code, self.message, self.data + ) // user-facing output + } }