Merge pull request #87 from QuantumEntangledAndy/error_updates

More detailed error messages on deser fail and timeout
This commit is contained in:
George Hilliard authored and GitHub committed 2020-11-30 23:35:26 -06:00
commit 32400971a5
2 files changed
+19 -2

No files matched your search

+13 -1
View File
@@ -50,7 +50,10 @@ pub enum Error {
DroppedConnection(#[error(source)] std::sync::mpsc::RecvError),
#[error(display = "Timeout")]
Timeout(#[error(source)] std::sync::mpsc::RecvTimeoutError),
Timeout,
#[error(display = "Dropped connection")]
TimeoutDisconnected,
#[error(display = "Credential error")]
AuthFailed,
@@ -62,6 +65,15 @@ pub enum Error {
Other(&'static str),
}
impl<'a> From<std::sync::mpsc::RecvTimeoutError> for Error {
fn from(k: std::sync::mpsc::RecvTimeoutError) -> Self {
match k {
std::sync::mpsc::RecvTimeoutError::Timeout => Error::Timeout,
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDisconnected,
}
}
}
impl Drop for BcCamera {
fn drop(&mut self) {
self.disconnect();
+6 -1
View File
@@ -55,7 +55,12 @@ impl BcConnection {
let rx_thread = std::thread::spawn(move || {
let mut context = BcContext::new();
while BcConnection::poll(&mut context, &conn, &mut subs).is_ok() {}
let mut result;
while {
result = BcConnection::poll(&mut context, &conn, &mut subs);
result.is_ok()
} {}
error!("Deserialization error: {:?}", result.unwrap_err());
});
Ok(BcConnection {