aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-07-16 17:06:15 +0100
committerNerdyPepper <[email protected]>2018-07-16 17:06:15 +0100
commit0f3fbe18193d7075febbc4ffe8c2a3a231734077 (patch)
tree588a29f98536ea955ece111d0f242a81fb024720
parent5b06a4ef9b8b2d9cc18f18c4ff6cfddf632f7483 (diff)
Attempt to remove more panic!s
-rw-r--r--Cargo.lock7
-rw-r--r--src/content.rs6
2 files changed, 10 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ddb4485..fe32c05 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -849,6 +849,7 @@ dependencies = [
849 "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 849 "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
850 "reqwest 0.8.6 (git+https://github.com/seanmonstar/reqwest)", 850 "reqwest 0.8.6 (git+https://github.com/seanmonstar/reqwest)",
851 "serde_json 1.0.20 (git+https://github.com/serde-rs/json)", 851 "serde_json 1.0.20 (git+https://github.com/serde-rs/json)",
852 "urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
852] 853]
853 854
854[[package]] 855[[package]]
@@ -1146,6 +1147,11 @@ dependencies = [
1146] 1147]
1147 1148
1148[[package]] 1149[[package]]
1150name = "urlencoding"
1151version = "1.0.0"
1152source = "registry+https://github.com/rust-lang/crates.io-index"
1153
1154[[package]]
1149name = "utf8-ranges" 1155name = "utf8-ranges"
1150version = "1.0.0" 1156version = "1.0.0"
1151source = "registry+https://github.com/rust-lang/crates.io-index" 1157source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1362,6 +1368,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1362"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 1368"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
1363"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" 1369"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
1364"checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" 1370"checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7"
1371"checksum urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3df3561629a8bb4c57e5a2e4c43348d9e29c7c29d9b1c4c1f47166deca8f37ed"
1365"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" 1372"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
1366"checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" 1373"checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363"
1367"checksum vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cbe533e138811704c0e3cbde65a818b35d3240409b4346256c5ede403e082474" 1374"checksum vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cbe533e138811704c0e3cbde65a818b35d3240409b4346256c5ede403e082474"
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 {
100pub fn get_search_results(search: &str) -> Result<Vec<String>, reqwest::Error> { 100pub 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 } );