aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMustafa Salih <37256744+MustafaSalih1993@users.noreply.github.com>2021-10-15 20:46:29 +0300
committerGitHub <noreply@github.com>2021-10-15 20:46:29 +0300
commitde2e6017f5ad0c6d3d6894d64b19c8da4dfe82d0 (patch)
tree424d29ab80732bdb4c1c476e5d43a7b738246b25 /src
parentae533f1fe7675efb8b63f0a176e1fafa23dd94f9 (diff)
a simple update to handle weather http reqwests (#64)
Diffstat (limited to 'src')
-rw-r--r--src/utils/weather.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/utils/weather.rs b/src/utils/weather.rs
index 10c887c..b284807 100644
--- a/src/utils/weather.rs
+++ b/src/utils/weather.rs
@@ -12,10 +12,16 @@ pub async fn get_weather() -> ThreadsData {
let url = format!("http://wttr.in/{}?format=\"{}", CONFIG.weather.city, format);
let err_string = String::from("Error");
let res = match minreq::get(url).send() {
- Ok(resp) => match resp.as_str() {
- Ok(res_str) => res_str.trim_matches('"').to_string(),
- Err(_) => err_string,
- },
+ Ok(resp) => {
+ if resp.status_code != 200 {
+ String::from("service error")
+ } else {
+ match resp.as_str() {
+ Ok(res_str) => res_str.trim_matches('"').to_string(),
+ Err(_) => err_string,
+ }
+ }
+ }
Err(_) => err_string,
};