forked from Silverfish/proton-bridge
Better error message when request is canceled
This commit is contained in:
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
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)
|
## [v1.2.7] Donghai-hotfix - beta (2020-05-07)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -56,6 +56,7 @@ var (
|
|||||||
ErrInvalidToken = errors.New("refresh token invalid")
|
ErrInvalidToken = errors.New("refresh token invalid")
|
||||||
ErrAPINotReachable = errors.New("cannot reach the server")
|
ErrAPINotReachable = errors.New("cannot reach the server")
|
||||||
ErrUpgradeApplication = errors.New("application upgrade required")
|
ErrUpgradeApplication = errors.New("application upgrade required")
|
||||||
|
ErrConnectionSlow = errors.New("request canceled because connection speed was too slow")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrUnprocessableEntity struct {
|
type ErrUnprocessableEntity struct {
|
||||||
@ -345,6 +346,9 @@ func (c *client) doJSONBuffered(req *http.Request, reqBodyBuffer []byte, data in
|
|||||||
resBody, err = ioutil.ReadAll(res.Body)
|
resBody, err = ioutil.ReadAll(res.Body)
|
||||||
} else {
|
} else {
|
||||||
resBody, err = c.readAllMinSpeed(res.Body, cancelRequest)
|
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
|
// The server response may contain data which we want to have in memory
|
||||||
|
|||||||
Reference in New Issue
Block a user