From b484872be8f7e04833d42fcec06170903bb33abf Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Mon, 16 Nov 2020 16:36:28 -0500 Subject: [PATCH] process::exit if the HapticsWorker dies --- src/dial_device/haptics.rs | 2 +- src/dial_device/mod.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dial_device/haptics.rs b/src/dial_device/haptics.rs index 3a4b012..a1412ed 100644 --- a/src/dial_device/haptics.rs +++ b/src/dial_device/haptics.rs @@ -58,7 +58,7 @@ impl DialHapticsWorker { eprintln!("haptics worker is ready"); let api = HidApi::new().map_err(Error::HidError)?; - let hid_device = api.open(0x045e, 0x091b).map_err(|_| Error::MissingDial)?; + let hid_device = api.open(0x045e, 0x091b).map_err(Error::HidError)?; let wrapper = DialHidWrapper { hid_device }; loop { diff --git a/src/dial_device/mod.rs b/src/dial_device/mod.rs index 21a46da..c644ea6 100644 --- a/src/dial_device/mod.rs +++ b/src/dial_device/mod.rs @@ -69,8 +69,12 @@ impl DialDevice { std::thread::spawn({ let mut worker = DialHapticsWorker::new(haptics_msg_rx)?; move || { - worker.run().unwrap(); + if let Err(err) = worker.run() { + eprintln!("Unexpected haptics worker error! {}", err); + } eprintln!("the haptics worker died!"); + // there's no coming back from this. + std::process::exit(0); } });