debug messages for bad position data

This commit is contained in:
Max Bradbury 2020-04-25 14:18:34 +01:00
parent 41a08d7a61
commit ed6552f39c
1 changed files with 2 additions and 2 deletions

View File

@ -10,13 +10,13 @@ impl Position {
pub(crate) fn from(string: String) -> Result<Position, &'static dyn Error> {
// e.g. "2,5"
let xy: Vec<&str> = string.split(',').collect();
let x = xy[0].parse().unwrap();
let x = xy[0].parse().expect("Bad x coordinate supplied for Position");
if xy.len() < 2 {
panic!("Bad position : {}", string);
}
let y = xy[1].parse().unwrap();
let y = xy[1].parse().expect("Bad y coordinate supplied for Position");
Ok(Position { x, y })
}