Handle timeout and dissconnect error differently
This commit is contained in:
3 files changed
+14
-11
No files matched your search
+12
-3
@@ -47,10 +47,10 @@ pub enum Error {
|
||||
DroppedConnection(#[error(source)] std::sync::mpsc::RecvError),
|
||||
|
||||
#[error(display = "Timeout")]
|
||||
Timeout(#[error(source)] std::sync::mpsc::RecvTimeoutError),
|
||||
Timeout,
|
||||
|
||||
#[error(display = "Media")]
|
||||
MediaPacket(#[error(source)] self::media_packet::Error),
|
||||
#[error(display = "Dropped connection")]
|
||||
TimeoutDisconnected,
|
||||
|
||||
#[error(display = "Credential error")]
|
||||
AuthFailed,
|
||||
@@ -59,6 +59,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();
|
||||
|
||||
@@ -59,7 +59,7 @@ impl BcConnection {
|
||||
match BcConnection::poll(&mut context, &conn, &mut subs) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
error!("Deserialization error: {}", err);
|
||||
error!("Deserialization error: {:?}", err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::bc::model::*;
|
||||
use crate::bc_protocol::connection::BcSubscription;
|
||||
use err_derive::Error;
|
||||
use crate::Error;
|
||||
use log::trace;
|
||||
use log::*;
|
||||
use std::collections::VecDeque;
|
||||
@@ -17,12 +17,6 @@ const PAD_SIZE: usize = 8;
|
||||
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "Timeout")]
|
||||
Timeout(#[error(source)] std::sync::mpsc::RecvTimeoutError),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
|
||||
pub enum MediaDataKind {
|
||||
VideoDataIframe,
|
||||
|
||||
Reference in new issue
Block a user