From 0f3fbe18193d7075febbc4ffe8c2a3a231734077 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 16 Jul 2018 21:36:15 +0530 Subject: Attempt to remove more panic!s --- src/content.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/content.rs b/src/content.rs index b72f4a8..7ebc129 100644 --- a/src/content.rs +++ b/src/content.rs @@ -46,7 +46,7 @@ pub fn get_extract(v: &Value) -> Result { let pageid = &v["query"]["pageids"][0]; let pageid_str = match pageid { Value::String(id) => id, - _ => panic!("wut"), + _ => "-1", }; match &v["query"]["pages"][pageid_str]["extract"] { @@ -57,7 +57,7 @@ pub fn get_extract(v: &Value) -> Result { Ok(format!("{}", extract)) } // ignore non strings - _ => Ok(format!("This page has been deleted or moved")) + _ => Ok(format!("This page does not exist anymore")) } } @@ -100,7 +100,7 @@ pub fn extract_formatter(extract: String) -> StyledString { pub fn get_search_results(search: &str) -> Result, reqwest::Error> { let url = search_url_gen(search); let mut res = reqwest::get(&url[..])?; - let v: Value = serde_json::from_str(&res.text().unwrap()) + let v: Value = serde_json::from_str(&res.text()?) .unwrap_or_else( |e| { panic!("Recieved error {:?}", e); } ); -- cgit v1.2.3