From 20c9f8209e35d2a178851a1b489e14dfce7cfb8c Mon Sep 17 00:00:00 2001 From: Pure White Date: Mon, 4 Mar 2024 23:10:28 +0800 Subject: [PATCH] feat(pilota): support clone for transport exception --- pilota/src/thrift/error/mod.rs | 2 +- pilota/src/thrift/error/transport.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pilota/src/thrift/error/mod.rs b/pilota/src/thrift/error/mod.rs index 3669bf07..ee855d20 100644 --- a/pilota/src/thrift/error/mod.rs +++ b/pilota/src/thrift/error/mod.rs @@ -19,7 +19,7 @@ pub use transport::*; /// processing. It is a catch-all for errors that occur in the Thrift /// runtime, including errors from the protocol, transport, and application /// layers. -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum ThriftException { /// Errors encountered within auto-generated code, or when incoming /// or outgoing messages violate the Thrift spec. diff --git a/pilota/src/thrift/error/transport.rs b/pilota/src/thrift/error/transport.rs index 42ced82c..dd8ec881 100644 --- a/pilota/src/thrift/error/transport.rs +++ b/pilota/src/thrift/error/transport.rs @@ -79,3 +79,14 @@ impl std::error::Error for TransportException { Some(&self.io_error) } } + +impl Clone for TransportException { + fn clone(&self) -> Self { + Self { + // TODO: io::Error doesn't support clone, we can only clone in this way now. + // Investigate how to do this in the future. + io_error: io::Error::new(self.io_error().kind(), self.io_error().to_string()), + message: self.message.clone(), + } + } +}