Implement Display for the error enum
This commit is contained in:
parent
f4d65a2c51
commit
b5870e62fe
10
src/lib.rs
10
src/lib.rs
@ -335,11 +335,19 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
|
||||
|
||||
// Create an error and result type for sending messages
|
||||
let error_enum = quote! {
|
||||
#[derive(Debug)]
|
||||
#[derive(::std::fmt::Debug)]
|
||||
#vis enum #error_enum_name {
|
||||
SendError(::tokio::sync::mpsc::error::SendError<(u64, #question_enum_name)>),
|
||||
Closed,
|
||||
}
|
||||
impl ::std::fmt::Display for #error_enum_name {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
match self {
|
||||
#error_enum_name::SendError(e) => write!(f, "Failed to send query: {}", e),
|
||||
#error_enum_name::Closed => write!(f, "Connection closed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// Create enums for the types of messages the server and client will use
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user