Handle connection errors in a better way
This commit is contained in:
parent
eea2ecbf63
commit
10c099e03b
@ -149,17 +149,17 @@ async fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> Res {
|
||||
|
||||
let client = match choice {
|
||||
ScreenResult::Ok(SelectPlayModeResult::PlayRandom) => {
|
||||
Client::start_random_play(&username).await?
|
||||
Client::start_random_play(&username).await
|
||||
}
|
||||
|
||||
// Play against bot
|
||||
ScreenResult::Ok(SelectPlayModeResult::PlayAgainstBot) => {
|
||||
Client::start_bot_play(&rules).await?
|
||||
Client::start_bot_play(&rules).await
|
||||
}
|
||||
|
||||
// Create invite
|
||||
ScreenResult::Ok(SelectPlayModeResult::CreateInvite) => {
|
||||
Client::start_create_invite(&rules, &username).await?
|
||||
Client::start_create_invite(&rules, &username).await
|
||||
}
|
||||
|
||||
// Join invite
|
||||
@ -175,15 +175,23 @@ async fn run_app<B: Backend>(terminal: &mut Terminal<B>) -> Res {
|
||||
};
|
||||
|
||||
PopupScreen::new("🔌 Connecting...").show_once(terminal)?;
|
||||
Client::start_accept_invite(code, &username).await?
|
||||
Client::start_accept_invite(code, &username).await
|
||||
}
|
||||
|
||||
ScreenResult::Canceled | ScreenResult::Ok(SelectPlayModeResult::Exit) => return Ok(()),
|
||||
};
|
||||
|
||||
match client {
|
||||
Ok(client) => {
|
||||
// Display game screen
|
||||
GameScreen::new(client).show(terminal).await?;
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to connect to server: {}", e);
|
||||
PopupScreen::new("❌ Failed to connect to server!").show(terminal)?;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
Loading…
Reference in New Issue
Block a user