Ensure consistent error handling and improve resource cleanup across widgets and APIs.
This commit is contained in:
+1
-2
@@ -28,8 +28,7 @@ func createWeather(ctx context.Context, _ terminalapi.Terminal, _ interface{}) w
|
||||
weather := openWeatherMap.FetchCurrentWeather()
|
||||
widget.Reset()
|
||||
if weather.ErrorMessage != "" {
|
||||
widget.Write(weather.ErrorMessage, text.WriteCellOpts(cell.FgColor(cell.ColorRed)))
|
||||
return nil
|
||||
return widget.Write(weather.ErrorMessage, text.WriteCellOpts(cell.FgColor(cell.ColorRed)))
|
||||
}
|
||||
|
||||
weatherIcon := getIcon(weather.Weather[0].Icon)
|
||||
|
||||
Reference in New Issue
Block a user