Unwrap io errors if its a bcerror

This commit is contained in:
QuantumEntangledAndy committed 2023-10-02 12:42:06 +07:00
1 parent 3d0f8b794e
commit 095bd889ef
1 file changed
+8 -1
+8 -1
View File
@@ -194,7 +194,14 @@ pub enum Error {
impl From<std::io::Error> for Error {
fn from(k: std::io::Error) -> Self {
Error::Io(std::sync::Arc::new(k))
// Check for other error that is already an Error of this type
if k.get_ref()
.is_some_and(|e| e.downcast_ref::<Error>().is_some())
{
*k.into_inner().unwrap().downcast::<Error>().unwrap()
} else {
Error::Io(std::sync::Arc::new(k))
}
}
}