From 5e9a94081cd9ff6fc11eb3d38063d68b933927b9 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 31 Oct 2020 19:13:45 -0600 Subject: [PATCH] remove unwrap --- src/ship/packet/handler/message.rs | 2 +- src/ship/ship.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index c1efe6b..937a08c 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -26,7 +26,7 @@ pub async fn request_exp(id: ClientId, .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?; let monster = room.maps.enemy_by_id(request_exp.enemy_id as usize)?; - let monster_stats = room.monster_stats.get(&monster.monster).unwrap(); + let monster_stats = room.monster_stats.get(&monster.monster).ok_or(ShipError::UnknownMonster(monster.monster.clone()))?; let exp_gain = if request_exp.last_hitter == 1 { monster_stats.exp diff --git a/src/ship/ship.rs b/src/ship/ship.rs index d431c96..ddbcb2d 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -66,6 +66,7 @@ pub enum ShipError { NotEnoughMeseta(ClientId, u32), ShopError, GatewayError(#[from] GatewayError), + UnknownMonster(crate::ship::monster::MonsterType), } #[derive(Debug)]