Better error handling of icon in weather module

This commit is contained in:
2025-07-19 20:21:20 -07:00
parent 7245914da8
commit 0e027005a1

View File

@@ -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());
}
}
}
}
}