Skip to content

Commit cc4c57b

Browse files
committed
check errors when creating request
related #494
1 parent 8a0fa05 commit cc4c57b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lastfm/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ func (c *Client) GetCurrentUser(user *db.User) (User, error) {
291291
}
292292

293293
func (c *Client) makeRequest(method string, params url.Values) (LastFM, error) {
294-
req, _ := http.NewRequest(method, BaseURL, nil)
294+
req, err := http.NewRequest(method, BaseURL, nil)
295+
if err != nil {
296+
return LastFM{}, fmt.Errorf("create request: %w", err)
297+
}
298+
295299
req.URL.RawQuery = params.Encode()
296300

297301
resp, err := c.httpClient.Do(req)

listenbrainz/listenbrainz.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ func (c *Client) Scrobble(user db.User, track scrobble.Track, stamp time.Time, s
7575
submitURL := fmt.Sprintf("%s%s", user.ListenBrainzURL, submitPath)
7676
authHeader := fmt.Sprintf("Token %s", user.ListenBrainzToken)
7777

78-
req, _ := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
78+
req, err := http.NewRequest(http.MethodPost, submitURL, &payloadBuf)
79+
if err != nil {
80+
return fmt.Errorf("create submit request: %w", err)
81+
}
82+
7983
req.Header.Add("Content-Type", "application/json")
8084
req.Header.Add("Authorization", authHeader)
8185

0 commit comments

Comments
 (0)