From e8d3e3c4f69fc5bab2b32b16b7c8c2c4a8a89a4b Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 6 Apr 2020 10:37:53 +0200 Subject: made parseerrors their own thing --- src/roomtemplate.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/roomtemplate.rs') diff --git a/src/roomtemplate.rs b/src/roomtemplate.rs index b5834e9..da4d3a5 100644 --- a/src/roomtemplate.rs +++ b/src/roomtemplate.rs @@ -4,8 +4,8 @@ use serde_json::{json, Value}; use crate::{ Pos, Template, - Result, - aerr + PResult, + perr }; #[derive(Debug, Clone)] @@ -18,39 +18,39 @@ pub struct RoomTemplate { impl RoomTemplate { - pub fn from_json(jsonroom: &Value) -> Result{ + pub fn from_json(jsonroom: &Value) -> PResult{ let size = ( - jsonroom.get("width").ok_or("no with")?.as_i64().ok_or("with not a number")?, - jsonroom.get("height").ok_or("no height")?.as_i64().ok_or("height not a number")? + jsonroom.get("width").ok_or(perr!("no with"))?.as_i64().ok_or(perr!("with not a number"))?, + jsonroom.get("height").ok_or(perr!("no height"))?.as_i64().ok_or(perr!("height not a number"))? ); - let spawn = Pos::from_json(jsonroom.get("spawn").ok_or("no spawn")?).ok_or("spawn not a pos")?; + let spawn = Pos::from_json(jsonroom.get("spawn").ok_or(perr!("no spawn"))?).ok_or(perr!("spawn not a pos"))?; let mut mapping = HashMap::new(); - for (key, value) in jsonroom.get("mapping").ok_or("no mapping")?.as_object().ok_or("mapping not a json object")?.iter() { + for (key, value) in jsonroom.get("mapping").ok_or(perr!("no mapping"))?.as_object().ok_or(perr!("mapping not a json object"))?.iter() { let mut templates: Vec