fix quorum err

This commit is contained in:
weisd
2024-09-24 10:39:12 +08:00
parent 29100d5250
commit dbb6980e96
11 changed files with 156 additions and 141 deletions
+17
View File
@@ -1,5 +1,9 @@
use std::io;
use tracing_error::{SpanTrace, SpanTraceStatus};
use crate::disk::error::{clone_disk_err, DiskError};
pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
@@ -80,3 +84,16 @@ impl std::fmt::Display for Error {
Ok(())
}
}
impl Clone for Error {
fn clone(&self) -> Self {
if let Some(e) = self.downcast_ref::<DiskError>() {
clone_disk_err(e)
} else if let Some(e) = self.downcast_ref::<io::Error>() {
Error::new(io::Error::new(e.kind(), e.to_string()))
} else {
// TODO: 优化其他类型
Error::msg(self.to_string())
}
}
}