diff options
author | NerdyPepper <[email protected]> | 2018-07-16 17:06:15 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2018-07-16 17:06:15 +0100 |
commit | 0f3fbe18193d7075febbc4ffe8c2a3a231734077 (patch) | |
tree | 588a29f98536ea955ece111d0f242a81fb024720 /src | |
parent | 5b06a4ef9b8b2d9cc18f18c4ff6cfddf632f7483 (diff) |
Attempt to remove more panic!s
Diffstat (limited to 'src')
-rw-r--r-- | src/content.rs | 6 |
1 files changed, 3 insertions, 3 deletions
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<String, reqwest::Error> { | |||
46 | let pageid = &v["query"]["pageids"][0]; | 46 | let pageid = &v["query"]["pageids"][0]; |
47 | let pageid_str = match pageid { | 47 | let pageid_str = match pageid { |
48 | Value::String(id) => id, | 48 | Value::String(id) => id, |
49 | _ => panic!("wut"), | 49 | _ => "-1", |
50 | }; | 50 | }; |
51 | 51 | ||
52 | match &v["query"]["pages"][pageid_str]["extract"] { | 52 | match &v["query"]["pages"][pageid_str]["extract"] { |
@@ -57,7 +57,7 @@ pub fn get_extract(v: &Value) -> Result<String, reqwest::Error> { | |||
57 | Ok(format!("{}", extract)) | 57 | Ok(format!("{}", extract)) |
58 | } | 58 | } |
59 | // ignore non strings | 59 | // ignore non strings |
60 | _ => Ok(format!("This page has been deleted or moved")) | 60 | _ => Ok(format!("This page does not exist anymore")) |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
@@ -100,7 +100,7 @@ pub fn extract_formatter(extract: String) -> StyledString { | |||
100 | pub fn get_search_results(search: &str) -> Result<Vec<String>, reqwest::Error> { | 100 | pub fn get_search_results(search: &str) -> Result<Vec<String>, reqwest::Error> { |
101 | let url = search_url_gen(search); | 101 | let url = search_url_gen(search); |
102 | let mut res = reqwest::get(&url[..])?; | 102 | let mut res = reqwest::get(&url[..])?; |
103 | let v: Value = serde_json::from_str(&res.text().unwrap()) | 103 | let v: Value = serde_json::from_str(&res.text()?) |
104 | .unwrap_or_else( |e| { | 104 | .unwrap_or_else( |e| { |
105 | panic!("Recieved error {:?}", e); | 105 | panic!("Recieved error {:?}", e); |
106 | } ); | 106 | } ); |