Skip to content

Commit 001ea80

Browse files
committed
Handle NewRequestWithContext error
1 parent 3edfd93 commit 001ea80

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ func sendRequest(client *http.Client, ctx context.Context, targetUrl string) (*S
242242
// Make a new GET request with the client trace
243243
req, err := http.NewRequestWithContext(httptrace.WithClientTrace(ctx, trace), "GET", targetUrl, nil)
244244

245+
if err != nil {
246+
return statistics, err
247+
}
248+
245249
req.Header.Set("User-Agent", userAgent)
246250

247251
// Send the request

0 commit comments

Comments
 (0)