Skip to content

Commit

Permalink
fix: Return an error if the context is nil (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
unfunco authored May 8, 2024
1 parent c1bda69 commit c284ec6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -94,7 +95,7 @@ func (c *Client) NewRequest(method, path string, body any) (*http.Request, error
// https://github.com/google/go-github/blob/master/github/github.go
func (c *Client) Do(ctx context.Context, req *http.Request, v any) (*http.Response, error) {
if ctx == nil {
ctx = context.Background()
return nil, errors.New("context must be non-nil")
}

req = req.WithContext(ctx)
Expand Down

0 comments on commit c284ec6

Please sign in to comment.