Skip to content

Commit

Permalink
Encourage printing deactivation error instead of panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano committed Sep 13, 2024
1 parent acf4fd0 commit cb708b2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ fn main() {
io::stdin().read_line(&mut user_input).ok();

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

Expand Down
4 changes: 3 additions & 1 deletion examples/playback_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ fn main() {
let mut user_input = String::new();
io::stdin().read_line(&mut user_input).ok();

active_client.deactivate().unwrap();
if let Err(err) = active_client.deactivate() {
eprintln!("JACK exited with error: {err}");
};
}

struct Notifications;
Expand Down
4 changes: 3 additions & 1 deletion examples/show_midi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,7 @@ fn main() {
io::stdin().read_line(&mut user_input).ok();

// Optional deactivation.
active_client.deactivate().unwrap();
if let Err(err) = active_client.deactivate() {
eprintln!("JACK exited with error: {err}");
};
}
4 changes: 3 additions & 1 deletion examples/sine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ fn main() {
// 6. Optional deactivate. Not required since active_client will deactivate on
// drop, though explicit deactivate may help you identify errors in
// deactivate.
active_client.deactivate().unwrap();
if let Err(err) = active_client.deactivate() {
eprintln!("JACK exited with error: {err}");
};
}

/// Attempt to read a frequency from standard in. Will block until there is
Expand Down
4 changes: 3 additions & 1 deletion src/client/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use crate::Error;
/// // An active async client is created, `client` is consumed.
/// let active_client = client.activate_async((), process_handler).unwrap();
/// // When done, deactivate the client.
/// active_client.deactivate().unwrap();
/// if let Err(err) = active_client.deactivate() {
/// eprintln!("Error deactivating client: {err}");
/// };
/// ```
#[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`."]
pub struct AsyncClient<N, P> {
Expand Down

0 comments on commit cb708b2

Please sign in to comment.