Skip to content

Commit 27a5102

Browse files
committed
Add error handling for unmarshalling response body
1 parent 77a9ebc commit 27a5102

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scraper/pkg/tripadvisor/tripadvisor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func MakeRequest(client *http.Client, queryID string, language []string, locatio
9595
responseData := Responses{}
9696
err = json.Unmarshal(responseBody, &responseData)
9797

98+
// Check for errors
99+
if err != nil {
100+
return nil, fmt.Errorf("error unmarshalling response body: %w", err)
101+
}
102+
98103
if os.Getenv("DEBUG") == "true" {
99104
fmt.Printf("Raw respsone:\n%s\n", string(responseBody))
100105
}

0 commit comments

Comments
 (0)