Handle non 200 response codes
This commit is contained in:
6 files changed
+22
No files matched your search
@@ -38,6 +38,10 @@ pub enum Error {
|
||||
why: &'static str,
|
||||
},
|
||||
|
||||
/// Raised when the camera responds with a status code over than OK
|
||||
#[error(display = "Camera responded with Service Unavaliable")]
|
||||
CameraServiceUnavaliable,
|
||||
|
||||
/// Raised when a connection is dropped.
|
||||
#[error(display = "Dropped connection")]
|
||||
DroppedConnection(#[error(source)] std::sync::mpsc::RecvError),
|
||||
|
||||
@@ -30,6 +30,9 @@ impl BcCamera {
|
||||
|
||||
sub_get.send(get)?;
|
||||
let msg = sub_get.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if msg.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload:
|
||||
|
||||
@@ -105,6 +105,9 @@ impl BcCamera {
|
||||
|
||||
sub_login.send(modern_login)?;
|
||||
let modern_reply = sub_login.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if modern_reply.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
|
||||
match modern_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
|
||||
@@ -30,6 +30,9 @@ impl BcCamera {
|
||||
|
||||
sub_get.send(get)?;
|
||||
let msg = sub_get.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if msg.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload:
|
||||
@@ -81,6 +84,9 @@ impl BcCamera {
|
||||
|
||||
sub_set.send(get)?;
|
||||
let msg = sub_set.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if msg.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
|
||||
if let BcMeta {
|
||||
response_code: 200, ..
|
||||
|
||||
@@ -31,6 +31,9 @@ impl BcCamera {
|
||||
|
||||
sub_get_general.send(get)?;
|
||||
let msg = sub_get_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if msg.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload:
|
||||
|
||||
@@ -28,6 +28,9 @@ impl BcCamera {
|
||||
sub_version.send(version)?;
|
||||
|
||||
let modern_reply = sub_version.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
if modern_reply.meta.response_code != 200 {
|
||||
return Err(Error::CameraServiceUnavaliable);
|
||||
}
|
||||
let version_info;
|
||||
match modern_reply.body {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
|
||||
Reference in new issue
Block a user