client.sendRequest: clean-up logic for error-handling

Only use checkResponseErr if `client.doRequest` did not return an error;
any error returned by `client.doRequest` means there was an error connecting,
so there's no response to handle (including errors in the response).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-12 23:22:03 +02:00
parent 2a4f70309d
commit f6b63e6013
2 changed files with 12 additions and 12 deletions

View File

@@ -123,14 +123,14 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
}
resp, err := cli.doRequest(req)
switch {
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
return nil, err
case err == nil:
return resp, checkResponseErr(resp)
default:
if err != nil {
// Failed to connect or context error.
return resp, err
}
// Successfully made a request; return the response and handle any
// API HTTP response errors.
return resp, checkResponseErr(resp)
}
// doRequest sends an HTTP request and returns an HTTP response. It is a

View File

@@ -123,14 +123,14 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
}
resp, err := cli.doRequest(req)
switch {
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
return nil, err
case err == nil:
return resp, checkResponseErr(resp)
default:
if err != nil {
// Failed to connect or context error.
return resp, err
}
// Successfully made a request; return the response and handle any
// API HTTP response errors.
return resp, checkResponseErr(resp)
}
// doRequest sends an HTTP request and returns an HTTP response. It is a