Ensure consistent error handling and improve resource cleanup across widgets and APIs.
This commit is contained in:
@@ -41,7 +41,12 @@ func FetchCurrentWeather() CurrentWeather {
|
||||
ErrorMessage: err.Error(),
|
||||
}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(resp.Body)
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return CurrentWeather{
|
||||
|
||||
Reference in New Issue
Block a user