diff --git a/src/lib.rs b/src/lib.rs index 4c879d2..b898e08 100644 --- a/src/lib.rs +++ b/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