Buttplug sex toy control library
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: Change several panics to warn messages

A lot of these can fire as the system spins down, and will crash

+37 -21
+15 -11
buttplug/src/server/device/hardware/communication/lovense_connect_service/lovense_connect_service_comm_manager.rs
··· 9 9 use crate::{ 10 10 core::errors::ButtplugDeviceError, 11 11 server::device::hardware::communication::{ 12 - HardwareCommunicationManager, 13 - HardwareCommunicationManagerBuilder, 14 - HardwareCommunicationManagerEvent, 15 - TimedRetryCommunicationManager, 12 + HardwareCommunicationManager, HardwareCommunicationManagerBuilder, 13 + HardwareCommunicationManagerEvent, TimedRetryCommunicationManager, 16 14 TimedRetryCommunicationManagerImpl, 17 15 }, 18 16 }; ··· 140 138 return None; 141 139 } 142 140 143 - let text = res 144 - .text() 145 - .await 146 - .expect("If we got a 200 back, we should at least have text."); 147 - let info: LovenseServiceLocalInfo = serde_json::from_str(&text) 148 - .expect("Should always get json back from service, if we got a response."); 149 - Some(info) 141 + match res.text().await { 142 + Ok(text) => match serde_json::from_str(&text) { 143 + Ok(info) => Some(info), 144 + Err(e) => { 145 + warn!("Should always get json back from service, if we got a response: ${e}"); 146 + None 147 + } 148 + }, 149 + Err(e) => { 150 + warn!("If we got a 200 back, we should at least have text: ${e}"); 151 + None 152 + } 153 + } 150 154 } 151 155 Err(err) => { 152 156 error!(
+14 -6
buttplug/src/server/device/hardware/communication/lovense_dongle/lovense_dongle_state_machine.rs
··· 139 139 } 140 140 141 141 pub async fn send_output(&self, msg: OutgoingLovenseData) { 142 - self 142 + if self 143 143 .dongle_outgoing 144 144 .send(msg) 145 145 .await 146 - .expect("Won't get here without owner being alive."); 146 + .is_err() { 147 + warn!("Dongle message sent without owner being alive, assuming shutdown."); 148 + } 147 149 } 148 150 149 151 pub async fn send_event(&self, msg: HardwareCommunicationManagerEvent) { ··· 254 256 self.is_scanning.store(false, Ordering::SeqCst); 255 257 should_scan = false; 256 258 // If we were requested to scan and then asked to stop, act like we at least tried. 257 - self 259 + if self 258 260 .event_sender 259 261 .send(HardwareCommunicationManagerEvent::ScanningFinished) 260 262 .await 261 - .expect("Won't get here without owner being alive."); 263 + .is_err() { 264 + warn!("Dongle message sent without owner being alive, assuming shutdown."); 265 + } 262 266 } 263 267 } 264 268 } ··· 660 664 } 661 665 } 662 666 } 663 - _ => device_read_sender 667 + _ => { 668 + if device_read_sender 664 669 .send(dongle_msg) 665 670 .await 666 - .expect("Won't get here if the parent isn't alive."), 671 + .is_err() { 672 + warn!("Dongle message sent without owner being alive, assuming shutdown."); 673 + } 674 + } 667 675 } 668 676 } 669 677 IncomingMessage::CommMgr(comm_msg) => match comm_msg {
+4 -2
buttplug/src/server/device/hardware/communication/lovense_dongle/lovense_hid_dongle_comm_manager.rs
··· 260 260 261 261 *(held_read_thread.lock().await) = Some(read_thread); 262 262 *(held_write_thread.lock().await) = Some(write_thread); 263 - machine_sender_clone 263 + if machine_sender_clone 264 264 .send(LovenseDeviceCommand::DongleFound( 265 265 writer_sender, 266 266 reader_receiver, 267 267 )) 268 268 .await 269 - .expect("We've already spun up the state machine so we know this receiver exists."); 269 + .is_err() { 270 + warn!("We've already spun up the state machine, this receiver should exist, but if we're shutting down this will throw."); 271 + } 270 272 info!("Found Lovense HID Dongle"); 271 273 Ok(()) 272 274 }
+4 -2
buttplug/src/server/device/hardware/communication/serialport/serialport_hardware.rs
··· 312 312 let data = msg.data.clone(); 313 313 // TODO Should check endpoint validity 314 314 async move { 315 - sender 315 + if sender 316 316 .send(data) 317 317 .await 318 - .expect("Tasks should exist if we get here."); 318 + .is_err() { 319 + warn!("Tasks should exist if we get here, but may not if we're shutting down"); 320 + } 319 321 Ok(()) 320 322 } 321 323 .boxed()