fix: check deprecated API statuscode first to better determine API error

create-reload-action
James Houlahan 5 years ago
parent 45efdad27e
commit cb839ff149
  1. 4
      pkg/pmapi/client.go
  2. 18
      pkg/pmapi/res.go
  3. 1
      unreleased.md

@ -43,9 +43,7 @@ const Version = 3
// API return codes.
const (
ForceUpgradeBadAPIVersion = 5003
ForceUpgradeInvalidAPI = 5004
ForceUpgradeBadAppVersion = 5005
ForceUpgradeBadAppVersion = 5003
APIOffline = 7001
ImportMessageTooLong = 36022
BansRequests = 85131

@ -41,22 +41,20 @@ type Res struct {
// Err returns error if the response is an error. Otherwise, returns nil.
func (res Res) Err() error {
if res.StatusCode == http.StatusUnprocessableEntity {
return &ErrUnprocessableEntity{errors.New(res.Error)}
if res.Code == ForceUpgradeBadAppVersion {
return ErrUpgradeApplication
}
if res.ResError == nil {
return nil
if res.Code == APIOffline {
return ErrAPINotReachable
}
if res.Code == ForceUpgradeBadAPIVersion ||
res.Code == ForceUpgradeInvalidAPI ||
res.Code == ForceUpgradeBadAppVersion {
return ErrUpgradeApplication
if res.StatusCode == http.StatusUnprocessableEntity {
return &ErrUnprocessableEntity{errors.New(res.Error)}
}
if res.Code == APIOffline {
return ErrAPINotReachable
if res.ResError == nil {
return nil
}
return &Error{

@ -58,3 +58,4 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
### Fixed
* GODT-900 Remove \Deleted flag after re-importing the message (do not delete messages by moving to local folder and back).
* GODT-908 Do not unpause event loop if other mailbox is still fetching.
* Check deprecated status code first to better determine API error.

Loading…
Cancel
Save