Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added error handling to file.close() fns #908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/dia/scraper/exchange-scrapers/BitstampScraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ func (s *BitstampScraper) FetchAvailablePairs() (pairs []dia.ExchangePair, err e
log.Error("Get Pairs:", err)
}

defer resp.Body.Close()
defer func() {
if err := resp.Body.Close(); err != nil {
log.Warn("Error closing file: ", err)
}
}()

body, err := io.ReadAll(resp.Body)
if err != nil {
log.Error("Read pair body:", err)
Expand Down
6 changes: 5 additions & 1 deletion pkg/dia/scraper/exchange-scrapers/MEXCScraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ func (s *MEXCScraper) FetchAvailablePairs() (pairs []dia.ExchangePair, err error
log.Error("get symbols: ", err)
}

defer response.Body.Close()
defer func() {
if err := response.Body.Close(); err != nil {
log.Warn("Error closing file: ", err)
}
}()

body, err := ioutil.ReadAll(response.Body)

Expand Down
6 changes: 5 additions & 1 deletion pkg/dia/service/assetservice/source/osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func GetAssetsJson() (map[string]*OsmosisAsset, error) {
if err != nil {
return nil, err
}
defer res.Body.Close()
defer func() {
if err := res.Body.Close(); err != nil {
log.Warn("Error closing file: ", err)
}
}()
data, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
Expand Down
7 changes: 6 additions & 1 deletion pkg/utils/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ func (cg *Coingecko) Price(assetName string) (float64, error) {
return 0.0, err
}

defer response.Body.Close()
defer func() {
if err := response.Body.Close(); err != nil {
log.Warn("Error closing file: ", err)
}
}()

if 200 != response.StatusCode {
return 0.0, fmt.Errorf("Error on coingecko API call with return code %d", response.StatusCode)
}
Expand Down