···99use crate::{
1010 core::errors::ButtplugDeviceError,
1111 server::device::hardware::communication::{
1212- HardwareCommunicationManager,
1313- HardwareCommunicationManagerBuilder,
1414- HardwareCommunicationManagerEvent,
1515- TimedRetryCommunicationManager,
1212+ HardwareCommunicationManager, HardwareCommunicationManagerBuilder,
1313+ HardwareCommunicationManagerEvent, TimedRetryCommunicationManager,
1614 TimedRetryCommunicationManagerImpl,
1715 },
1816};
···140138 return None;
141139 }
142140143143- let text = res
144144- .text()
145145- .await
146146- .expect("If we got a 200 back, we should at least have text.");
147147- let info: LovenseServiceLocalInfo = serde_json::from_str(&text)
148148- .expect("Should always get json back from service, if we got a response.");
149149- Some(info)
141141+ match res.text().await {
142142+ Ok(text) => match serde_json::from_str(&text) {
143143+ Ok(info) => Some(info),
144144+ Err(e) => {
145145+ warn!("Should always get json back from service, if we got a response: ${e}");
146146+ None
147147+ }
148148+ },
149149+ Err(e) => {
150150+ warn!("If we got a 200 back, we should at least have text: ${e}");
151151+ None
152152+ }
153153+ }
150154 }
151155 Err(err) => {
152156 error!(
···139139 }
140140141141 pub async fn send_output(&self, msg: OutgoingLovenseData) {
142142- self
142142+ if self
143143 .dongle_outgoing
144144 .send(msg)
145145 .await
146146- .expect("Won't get here without owner being alive.");
146146+ .is_err() {
147147+ warn!("Dongle message sent without owner being alive, assuming shutdown.");
148148+ }
147149 }
148150149151 pub async fn send_event(&self, msg: HardwareCommunicationManagerEvent) {
···254256 self.is_scanning.store(false, Ordering::SeqCst);
255257 should_scan = false;
256258 // If we were requested to scan and then asked to stop, act like we at least tried.
257257- self
259259+ if self
258260 .event_sender
259261 .send(HardwareCommunicationManagerEvent::ScanningFinished)
260262 .await
261261- .expect("Won't get here without owner being alive.");
263263+ .is_err() {
264264+ warn!("Dongle message sent without owner being alive, assuming shutdown.");
265265+ }
262266 }
263267 }
264268 }
···660664 }
661665 }
662666 }
663663- _ => device_read_sender
667667+ _ => {
668668+ if device_read_sender
664669 .send(dongle_msg)
665670 .await
666666- .expect("Won't get here if the parent isn't alive."),
671671+ .is_err() {
672672+ warn!("Dongle message sent without owner being alive, assuming shutdown.");
673673+ }
674674+ }
667675 }
668676 }
669677 IncomingMessage::CommMgr(comm_msg) => match comm_msg {
···260260261261 *(held_read_thread.lock().await) = Some(read_thread);
262262 *(held_write_thread.lock().await) = Some(write_thread);
263263- machine_sender_clone
263263+ if machine_sender_clone
264264 .send(LovenseDeviceCommand::DongleFound(
265265 writer_sender,
266266 reader_receiver,
267267 ))
268268 .await
269269- .expect("We've already spun up the state machine so we know this receiver exists.");
269269+ .is_err() {
270270+ warn!("We've already spun up the state machine, this receiver should exist, but if we're shutting down this will throw.");
271271+ }
270272 info!("Found Lovense HID Dongle");
271273 Ok(())
272274 }
···312312 let data = msg.data.clone();
313313 // TODO Should check endpoint validity
314314 async move {
315315- sender
315315+ if sender
316316 .send(data)
317317 .await
318318- .expect("Tasks should exist if we get here.");
318318+ .is_err() {
319319+ warn!("Tasks should exist if we get here, but may not if we're shutting down");
320320+ }
319321 Ok(())
320322 }
321323 .boxed()