Better error handling of icon in weather module
This commit is contained in:
@@ -251,9 +251,16 @@ impl bar_modules::BarModuleActions for UnibarModuleWeather {
|
||||
// "icon": "https://api.weather.gov/icons/land/night/ovc?size=medium",
|
||||
let re = Regex::new(r"(\w+)\?size").unwrap();
|
||||
let json_val = self.weather_info["features"][0]["properties"]["icon"].to_string();
|
||||
let caps = re.captures(&json_val).unwrap();
|
||||
match self.weather_info["features"][0]["properties"]["icon"] {
|
||||
serde_json::Value::Null => {
|
||||
return "⁈".to_string();
|
||||
}
|
||||
_ => {
|
||||
let caps = re.captures(&json_val).unwrap();
|
||||
|
||||
return self.get_unicode_symbol(caps.get(1).unwrap().as_str());
|
||||
return self.get_unicode_symbol(caps.get(1).unwrap().as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user