Ensure consistent error handling and improve resource cleanup across widgets and APIs.
This commit is contained in:
@@ -57,7 +57,12 @@ func FetchWarnings() []Warning {
|
||||
Errormsg: 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 append(make([]Warning, 0), Warning{
|
||||
@@ -86,7 +91,12 @@ func FetchWarnings() []Warning {
|
||||
Errormsg: 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 append(make([]Warning, 0), Warning{
|
||||
|
||||
Reference in New Issue
Block a user