From e8ab11eff903861e1c0839746319e3f32f80d621 Mon Sep 17 00:00:00 2001 From: Mahesh Asolkar Date: Sat, 14 Jun 2025 16:55:26 -0700 Subject: [PATCH] More null handling in weather API responses --- src/bar_modules/bar_module_weather.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bar_modules/bar_module_weather.rs b/src/bar_modules/bar_module_weather.rs index 0ec6dfc..bf31ba1 100644 --- a/src/bar_modules/bar_module_weather.rs +++ b/src/bar_modules/bar_module_weather.rs @@ -33,9 +33,10 @@ impl UnibarModuleWeather { } _ => { deg_c = self.weather_info["features"][0]["properties"]["temperature"]["value"] - .to_string().parse().unwrap(); + .to_string().parse().unwrap(); } } + match self.opts.weather_units { common::TemperatureUnits::Metric => return deg_c, common::TemperatureUnits::Imperial => return (deg_c * 9.0 / 5.0) + 32.0, @@ -203,6 +204,10 @@ impl bar_modules::BarModuleActions for UnibarModuleWeather { "".to_string() }); self.weather_info = serde_json::from_str(curl_reg_str.as_str()).unwrap(); + + if self.weather_info["features"][0]["properties"]["temperature"]["value"] == serde_json::Value::Null { + self.weather_info = serde_json::Value::Null; + } } }