Skip to content

Commit

Permalink
fix(example): remove panics from the example
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-faber committed Dec 10, 2020
1 parent bb56857 commit 20dfe02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 11 additions & 5 deletions examples/echo_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ async fn main() -> Result<(), Error> {
let (bootstrap_nodes, genesis) = match &args[1][..] {
"create" => (vec![], true),
"connect" => {
let bootstrap_node = args[2]
.parse()
.map_err(|_| Error::Unexpected("SocketAddr format not recognized".to_string()))?;
let bootstrap_node = args[2].parse().map_err(|_| {
Error::Configuration("SocketAddr format not recognized".to_string())
})?;
(vec![bootstrap_node], false)
}
_ => panic!("Unexpected argument"),
other => {
return Err(Error::Configuration(format!(
"Unexpected argument: {}",
other
)));
}
};
let qp2p = QuicP2p::with_config(
Some(Config {
Expand Down Expand Up @@ -43,7 +48,8 @@ async fn main() -> Result<(), Error> {
{
(bytes, send, recv)
} else {
panic!("This example only supports bi-streams");
println!("Only bidirectional streams are supported in this example");
return Err(Error::OperationNotAllowed);
};
loop {
println!(
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ impl BootstrapCache {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
use crate::test_utils::{make_node_addr, rand_node_addr, test_dirs};
Expand Down

0 comments on commit 20dfe02

Please sign in to comment.