mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-19 00:27:06 +00:00
fix: check deprecated API statuscode first to better determine API error
This commit is contained in:
@ -41,6 +41,14 @@ type Res struct {
|
||||
|
||||
// Err returns error if the response is an error. Otherwise, returns nil.
|
||||
func (res Res) Err() error {
|
||||
if res.Code == ForceUpgradeBadAppVersion {
|
||||
return ErrUpgradeApplication
|
||||
}
|
||||
|
||||
if res.Code == APIOffline {
|
||||
return ErrAPINotReachable
|
||||
}
|
||||
|
||||
if res.StatusCode == http.StatusUnprocessableEntity {
|
||||
return &ErrUnprocessableEntity{errors.New(res.Error)}
|
||||
}
|
||||
@ -49,16 +57,6 @@ func (res Res) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if res.Code == ForceUpgradeBadAPIVersion ||
|
||||
res.Code == ForceUpgradeInvalidAPI ||
|
||||
res.Code == ForceUpgradeBadAppVersion {
|
||||
return ErrUpgradeApplication
|
||||
}
|
||||
|
||||
if res.Code == APIOffline {
|
||||
return ErrAPINotReachable
|
||||
}
|
||||
|
||||
return &Error{
|
||||
Code: res.Code,
|
||||
ErrorMessage: res.ResError.Error,
|
||||
|
||||
Reference in New Issue
Block a user