Skip to content

Commit

Permalink
Log better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvio Böhler committed Aug 29, 2023
1 parent ec8227e commit 0d9877d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/quotes/yahoo/yahoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ func New() Client {
func (c *Client) Fetch(sym string, t0, t1 time.Time) ([]Quote, error) {
u, err := createURL(c.url, sym, t0, t1)
if err != nil {
return nil, err
return nil, fmt.Errorf("error creating URL for symbol %s: %w", sym, err)
}
resp, err := http.Get(u.String())
if err != nil {
return nil, err
return nil, fmt.Errorf("error fetching data from URL %s: %w", u.String(), err)
}
defer resp.Body.Close()
return decodeResponse(resp.Body)
quote, err := decodeResponse(resp.Body)
if err != nil {
return nil, fmt.Errorf("error decoding response for symbol %s: %w", sym, err)
}
return quote, nil
}

// createURL creates a URL for the given root URL and parameters.
Expand Down

0 comments on commit 0d9877d

Please sign in to comment.