From 880bfc620a9484c0010c4f0b3ee3e4fc5925a027 Mon Sep 17 00:00:00 2001 From: mht8355 Date: Tue, 28 Apr 2020 01:25:50 -0400 Subject: [PATCH] added some error handling --- src/ship/packet/builder/lobby.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ship/packet/builder/lobby.rs b/src/ship/packet/builder/lobby.rs index 8677da1..84f1d14 100644 --- a/src/ship/packet/builder/lobby.rs +++ b/src/ship/packet/builder/lobby.rs @@ -65,8 +65,10 @@ pub fn add_to_lobby(id: ClientId, pub fn remove_from_lobby(id: ClientId, client_location: &ClientLocation) -> Result { - let prev_area_index = client_location.get_local_client(id).unwrap().local_client.id(); - let prev_area_leader_index = client_location.get_area_leader(client_location.get_area(id).unwrap()).unwrap().local_client.id(); + let prev_area_index = client_location.get_local_client(id).map_err(|err| -> ClientLocationError { err.into() })?.local_client.id(); + let prev_area_leader_index = client_location.get_area_leader(client_location.get_area(id) + .map_err(|err| -> ClientLocationError { err.into() })?) + .map_err(|err| -> ClientLocationError { err.into() })?.local_client.id(); Ok(LeaveLobby { client: prev_area_index, leader: prev_area_leader_index,