Skip to content

Commit cb708b2

Browse files
committed
Encourage printing deactivation error instead of panic.
1 parent acf4fd0 commit cb708b2

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

docs/quickstart.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ fn main() {
9191
io::stdin().read_line(&mut user_input).ok();
9292

9393
// 5. Not needed as the async client will cease processing on `drop`.
94-
active_client.deactivate().unwrap();
94+
if let Err(err) = active_client.deactivate() {
95+
eprintln!("JACK exited with error: {err}");
96+
}
9597
}
9698
```
9799

examples/playback_capture.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ fn main() {
4141
let mut user_input = String::new();
4242
io::stdin().read_line(&mut user_input).ok();
4343

44-
active_client.deactivate().unwrap();
44+
if let Err(err) = active_client.deactivate() {
45+
eprintln!("JACK exited with error: {err}");
46+
};
4547
}
4648

4749
struct Notifications;

examples/show_midi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,7 @@ fn main() {
105105
io::stdin().read_line(&mut user_input).ok();
106106

107107
// Optional deactivation.
108-
active_client.deactivate().unwrap();
108+
if let Err(err) = active_client.deactivate() {
109+
eprintln!("JACK exited with error: {err}");
110+
};
109111
}

examples/sine.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ fn main() {
6666
// 6. Optional deactivate. Not required since active_client will deactivate on
6767
// drop, though explicit deactivate may help you identify errors in
6868
// deactivate.
69-
active_client.deactivate().unwrap();
69+
if let Err(err) = active_client.deactivate() {
70+
eprintln!("JACK exited with error: {err}");
71+
};
7072
}
7173

7274
/// Attempt to read a frequency from standard in. Will block until there is

src/client/async_client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use crate::Error;
2828
/// // An active async client is created, `client` is consumed.
2929
/// let active_client = client.activate_async((), process_handler).unwrap();
3030
/// // When done, deactivate the client.
31-
/// active_client.deactivate().unwrap();
31+
/// if let Err(err) = active_client.deactivate() {
32+
/// eprintln!("Error deactivating client: {err}");
33+
/// };
3234
/// ```
3335
#[must_use = "The jack client is shut down when the AsyncClient is dropped. You most likely want to keep this alive and manually tear down with `AsyncClient::deactivate`."]
3436
pub struct AsyncClient<N, P> {

0 commit comments

Comments
 (0)