Skip to content

Commit

Permalink
Fix panic inside panic
Browse files Browse the repository at this point in the history
  • Loading branch information
shenkeyao committed Aug 4, 2023
1 parent 165c30f commit 031ec68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion centralized_server/benchmark_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ async fn main() {
.unwrap_or_else(|e| panic!("Could not resolve addr {}: {e:?}", opts.addr))
.collect::<Vec<_>>();
if addr.len() != 1 {
panic!(
// Create the message before calling `panic!` to avoid the `illegal instruction` error
// caused by a panic inside a panic.
let msg = format!(
"{} resolves to {} addresses, cannot continue",
opts.addr,
addr.len()
);
panic!("{}", msg);
}
let (read, write) = split_stream(
TcpStream::connect(addr[0])
Expand Down

0 comments on commit 031ec68

Please sign in to comment.