Better error message when request is canceled

This commit is contained in:
Michal Horejsek
2020-05-12 12:01:43 +02:00
parent f87ca36ffd
commit 6147c214c3
2 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,11 @@
Changelog [format](http://keepachangelog.com/en/1.0.0/)
## unreleased
### Changed
* GODT-308 better user error message when request is canceled
## [v1.2.7] Donghai-hotfix - beta (2020-05-07)
### Added

View File

@ -56,6 +56,7 @@ var (
ErrInvalidToken = errors.New("refresh token invalid")
ErrAPINotReachable = errors.New("cannot reach the server")
ErrUpgradeApplication = errors.New("application upgrade required")
ErrConnectionSlow = errors.New("request canceled because connection speed was too slow")
)
type ErrUnprocessableEntity struct {
@ -345,6 +346,9 @@ func (c *client) doJSONBuffered(req *http.Request, reqBodyBuffer []byte, data in
resBody, err = ioutil.ReadAll(res.Body)
} else {
resBody, err = c.readAllMinSpeed(res.Body, cancelRequest)
if err == context.Canceled {
err = ErrConnectionSlow
}
}
// The server response may contain data which we want to have in memory