Skip to content

Commit

Permalink
feat(pilota): support clone for transport exception
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWhiteWu committed Mar 4, 2024
1 parent 7683530 commit 20c9f82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pilota/src/thrift/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions pilota/src/thrift/error/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}

0 comments on commit 20c9f82

Please sign in to comment.