Skip to content

Commit

Permalink
src: device: manager: Fix panic when call unimplemented options
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Jul 19, 2024
1 parent 1a6c538 commit 1d84f90
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/device/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};
use tokio::sync::{mpsc, oneshot};
use tokio_serial::{SerialPort, SerialPortBuilderExt, SerialStream};
use tracing::{error, info, trace};
use tracing::{error, info, trace, warn};
use udp_stream::UdpStream;
use uuid::Uuid;

Expand Down Expand Up @@ -109,6 +109,7 @@ pub enum ManagerError {
DeviceSourceError(String),
NoDevices,
TokioMpsc(String),
NotImplemented(Request),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -174,7 +175,14 @@ impl DeviceManager {
);
}
}
_ => todo!(), // Unreachable, DeviceManagerHandler uses GetDeviceHandler and forwards the requests.
_ => {
if let Err(e) = actor_request
.respond_to
.send(Err(ManagerError::NotImplemented(actor_request.request)))
{
warn!("DeviceManager: Failed to return response: {:?}", e);
}
}
}
}

Expand Down

0 comments on commit 1d84f90

Please sign in to comment.