From 1967be36351cf0b13a6fc866d83a0cc8a4d2ba1d Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Fri, 16 Oct 2020 16:04:55 +0100 Subject: [PATCH] return error instead of panicking on sprite missing position --- src/sprite.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sprite.rs b/src/sprite.rs index a72d476..2e51445 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -84,7 +84,11 @@ impl Sprite { return Err(SpriteMissingRoomPosition); } - position = Some(Position::from_str(room_position[1]).unwrap()); + if let Ok(pos) = Position::from_str(room_position[1]) { + position = Some(pos); + } else { + return Err(SpriteMissingRoomPosition); + } } else if last_line.starts_with("COL") { colour_id = Some(last_line.replace("COL ", "").parse().unwrap()); } else if last_line.starts_with("ITM") {