impr: add custom context and custom client posibility #15

This commit is contained in:
Mike Berezin
2023-01-12 12:54:18 +05:00
parent 1b1e6e9e92
commit 7ef8b42b8d
9 changed files with 114 additions and 33 deletions

View File

@@ -7,7 +7,7 @@ package airtable
import (
"fmt"
"io/ioutil"
"io"
"net/http"
)
@@ -48,7 +48,7 @@ func makeHTTPClientError(url string, resp *http.Response) error {
respStatusText = "The server could not process your request in time. The server could be temporarily unavailable, or it could have timed out processing your request. You should retry the request with backoffs."
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
resError = fmt.Errorf("HTTP request failure on %s:\n%d %s\n%s\n\nCannot parse body with err: %w",
url, resp.StatusCode, resp.Status, respStatusText, err)