diff --git a/src/gameslot.rs b/src/gameslot.rs index fc59e04..ec26f92 100644 --- a/src/gameslot.rs +++ b/src/gameslot.rs @@ -12,6 +12,7 @@ pub enum InsertionStatus { LengthError, InvalidChar, GameOver, + UnknownError, } #[derive(Clone, Debug)] @@ -83,7 +84,7 @@ impl Game { (0..=5, _, &GameStatus::Playing, true) => InsertionStatus::LengthError, (0..=5, 5, &GameStatus::Playing, false) => InsertionStatus::InvalidChar, (_, _, &GameStatus::Win(_) | &GameStatus::Fail, _) => InsertionStatus::GameOver, - _ => todo!(), + _ => InsertionStatus::UnknownError, }; self.last_insertion_status = insertion_status.clone(); insertion_status diff --git a/src/main.rs b/src/main.rs index a619bf5..6814b7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,7 +108,8 @@ async fn main() -> Result<(), Box> { } InsertionStatus::LengthError => { Some("La palabra debe de ser de 5 letras".to_string()) - } + }, + InsertionStatus::UnknownError => Some("A chinga', error inesperado.".to_string()) }; result_pattern = None; } @@ -149,6 +150,7 @@ async fn main() -> Result<(), Box> { .mount("/:uuid/:attempt", move |request| async move { let mut context = tera::Context::new(); + // This should be safe because you can only get into the route with the right path let possible_uuid = request.parameters.get("uuid").unwrap(); let attempt = urlencoding::decode(request.parameters.get("attempt").unwrap()).unwrap().to_string();