implement std::error::Error for the error type
All checks were successful
Build library & run tests / build (unix) (push) Successful in 33s
Build library & run tests / build (tcp) (push) Successful in 34s
Build library & run tests / docs (push) Successful in 35s

This commit is contained in:
Kodi Craft 2024-06-25 00:03:29 +02:00
parent bffb41e8a1
commit 267b741ac4
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -348,6 +348,26 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
} }
} }
} }
impl ::std::error::Error for #error_enum_name {
fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
match self {
#error_enum_name::SendError(e) => ::std::option::Option::Some(e),
#error_enum_name::Closed => ::std::option::Option::None,
}
}
fn description(&self) -> &str {
match self {
#error_enum_name::SendError(_) => "Failed to send query",
#error_enum_name::Closed => "Connection closed",
}
}
fn cause(&self) -> ::std::option::Option<&dyn ::std::error::Error> {
match self {
#error_enum_name::SendError(e) => ::std::option::Option::Some(e),
#error_enum_name::Closed => ::std::option::Option::None,
}
}
}
}; };
// Create enums for the types of messages the server and client will use // Create enums for the types of messages the server and client will use