move ecsotre/error to common

This commit is contained in:
weisd
2025-03-25 17:14:40 +08:00
parent c3b47adf39
commit 545ae79e44
81 changed files with 444 additions and 359 deletions
+5
View File
@@ -61,6 +61,11 @@ impl Error {
pub fn downcast_mut<T: std::error::Error + 'static>(&mut self) -> Option<&mut T> {
self.inner.downcast_mut()
}
pub fn to_io_err(&self) -> Option<std::io::Error> {
self.downcast_ref::<std::io::Error>()
.map(|e| std::io::Error::new(e.kind(), e.to_string()))
}
}
impl<T: std::error::Error + Send + Sync + 'static> From<T> for Error {