implement std::error::Error for the error type
This commit is contained in:
parent
bffb41e8a1
commit
267b741ac4
20
src/lib.rs
20
src/lib.rs
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user