Add more retryable IO errors

This commit is contained in:
QuantumEntangledAndy committed 2023-10-08 18:01:48 +07:00
1 parent acaa4703df
commit 1195087d4b
1 file changed
+33 -19
+33 -19
View File
@@ -131,19 +131,26 @@ impl NeoInstance {
},
Ok(neolink_core::Error::Io(e)) => {
log::debug!("Std IO Error");
// Check if the inner error is the Other type and then the discomnect
let is_dropped = e.get_ref().is_some_and(|e| {
log::debug!("Std IO Error: Inner: {:?}", e);
matches!(e.downcast_ref::<neolink_core::Error>(),
Some(neolink_core::Error::DroppedConnection) | Some(neolink_core::Error::TimeoutDisconnected)
)
});
if is_dropped {
// Retry is a None
use std::io::ErrorKind::*;
if let ConnectionReset | ConnectionAborted | BrokenPipe | TimedOut = e.kind() {
// Resetable IO
camera = None;
None
} else {
Some(Err(e.into()))
// Check if the inner error is the Other type and then the discomnect
let is_dropped = e.get_ref().is_some_and(|e| {
log::debug!("Std IO Error: Inner: {:?}", e);
matches!(e.downcast_ref::<neolink_core::Error>(),
Some(neolink_core::Error::DroppedConnection) | Some(neolink_core::Error::TimeoutDisconnected)
)
});
if is_dropped {
// Retry is a None
camera = None;
None
} else {
Some(Err(e.into()))
}
}
}
Ok(e) => Some(Err(e.into())),
@@ -154,18 +161,25 @@ impl NeoInstance {
Ok(e) => {
log::debug!("Std IO Error");
// Check if the inner error is the Other type and then the discomnect
let is_dropped = e.get_ref().is_some_and(|e| {
log::debug!("Std IO Error: Inner: {:?}", e);
matches!(e.downcast_ref::<neolink_core::Error>(),
Some(neolink_core::Error::DroppedConnection) | Some(neolink_core::Error::TimeoutDisconnected)
)
});
if is_dropped {
// Retry is a None
use std::io::ErrorKind::*;
if let ConnectionReset | ConnectionAborted | BrokenPipe | TimedOut = e.kind() {
// Resetable IO
camera = None;
None
} else {
Some(Err(e.into()))
let is_dropped = e.get_ref().is_some_and(|e| {
log::debug!("Std IO Error: Inner: {:?}", e);
matches!(e.downcast_ref::<neolink_core::Error>(),
Some(neolink_core::Error::DroppedConnection) | Some(neolink_core::Error::TimeoutDisconnected)
)
});
if is_dropped {
// Retry is a None
camera = None;
None
} else {
Some(Err(e.into()))
}
}
},
Err(e) => {