no unwraps! (except on locks)
This commit is contained in:
parent
6636920752
commit
a596932aed
1 changed files with 7 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::api::{greeting, Message, User};
|
||||
use crate::AppState;
|
||||
use crate::Arc;
|
||||
use anyhow::Result;
|
||||
use lib::models::*;
|
||||
|
||||
pub async fn message_handler(message: Message, state: &Arc<AppState>, who: &User) {
|
||||
|
@ -12,9 +13,12 @@ pub async fn message_handler(message: Message, state: &Arc<AppState>, who: &User
|
|||
tracing::debug!("New game request received.");
|
||||
// create game
|
||||
if let Ok(new_game_object) = Game::new(new_game) {
|
||||
let game_json = serde_json::to_string(&new_game_object).unwrap();
|
||||
if let Ok(game_json) = serde_json::to_string(&new_game_object) {
|
||||
tracing::debug!("Sent new game JSON.");
|
||||
let _ = tx.send(game_json);
|
||||
} else {
|
||||
tracing::error!("Failed to convert Game object to JSON.")
|
||||
}
|
||||
state.games.lock().unwrap().push(new_game_object);
|
||||
let _update = tx.send(greeting(state));
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue