mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 22:56:48 +00:00
fix: check deprecated API statuscode first to better determine API error
This commit is contained in:
@ -43,9 +43,7 @@ const Version = 3
|
|||||||
|
|
||||||
// API return codes.
|
// API return codes.
|
||||||
const (
|
const (
|
||||||
ForceUpgradeBadAPIVersion = 5003
|
ForceUpgradeBadAppVersion = 5003
|
||||||
ForceUpgradeInvalidAPI = 5004
|
|
||||||
ForceUpgradeBadAppVersion = 5005
|
|
||||||
APIOffline = 7001
|
APIOffline = 7001
|
||||||
ImportMessageTooLong = 36022
|
ImportMessageTooLong = 36022
|
||||||
BansRequests = 85131
|
BansRequests = 85131
|
||||||
|
|||||||
@ -41,6 +41,14 @@ type Res struct {
|
|||||||
|
|
||||||
// Err returns error if the response is an error. Otherwise, returns nil.
|
// Err returns error if the response is an error. Otherwise, returns nil.
|
||||||
func (res Res) Err() error {
|
func (res Res) Err() error {
|
||||||
|
if res.Code == ForceUpgradeBadAppVersion {
|
||||||
|
return ErrUpgradeApplication
|
||||||
|
}
|
||||||
|
|
||||||
|
if res.Code == APIOffline {
|
||||||
|
return ErrAPINotReachable
|
||||||
|
}
|
||||||
|
|
||||||
if res.StatusCode == http.StatusUnprocessableEntity {
|
if res.StatusCode == http.StatusUnprocessableEntity {
|
||||||
return &ErrUnprocessableEntity{errors.New(res.Error)}
|
return &ErrUnprocessableEntity{errors.New(res.Error)}
|
||||||
}
|
}
|
||||||
@ -49,16 +57,6 @@ func (res Res) Err() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if res.Code == ForceUpgradeBadAPIVersion ||
|
|
||||||
res.Code == ForceUpgradeInvalidAPI ||
|
|
||||||
res.Code == ForceUpgradeBadAppVersion {
|
|
||||||
return ErrUpgradeApplication
|
|
||||||
}
|
|
||||||
|
|
||||||
if res.Code == APIOffline {
|
|
||||||
return ErrAPINotReachable
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Error{
|
return &Error{
|
||||||
Code: res.Code,
|
Code: res.Code,
|
||||||
ErrorMessage: res.ResError.Error,
|
ErrorMessage: res.ResError.Error,
|
||||||
|
|||||||
@ -58,3 +58,4 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
### Fixed
|
### Fixed
|
||||||
* GODT-900 Remove \Deleted flag after re-importing the message (do not delete messages by moving to local folder and back).
|
* 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.
|
* GODT-908 Do not unpause event loop if other mailbox is still fetching.
|
||||||
|
* Check deprecated status code first to better determine API error.
|
||||||
|
|||||||
Reference in New Issue
Block a user