Add separate error code for requested entity not found errors

This commit is contained in:
Tulir Asokan 2023-09-04 14:33:08 +03:00
parent e863120b51
commit a4bb7e69cf
2 changed files with 4 additions and 2 deletions

View file

@ -27,6 +27,7 @@ const (
GMListenError status.BridgeStateErrorCode = "gm-listen-error" GMListenError status.BridgeStateErrorCode = "gm-listen-error"
GMFatalError status.BridgeStateErrorCode = "gm-listen-fatal-error" GMFatalError status.BridgeStateErrorCode = "gm-listen-fatal-error"
GMUnpaired status.BridgeStateErrorCode = "gm-unpaired" GMUnpaired status.BridgeStateErrorCode = "gm-unpaired"
GMUnpaired404 status.BridgeStateErrorCode = "gm-unpaired-entity-not-found"
GMNotConnected status.BridgeStateErrorCode = "gm-not-connected" GMNotConnected status.BridgeStateErrorCode = "gm-not-connected"
GMConnecting status.BridgeStateErrorCode = "gm-connecting" GMConnecting status.BridgeStateErrorCode = "gm-connecting"
GMConnectionFailed status.BridgeStateErrorCode = "gm-connection-failed" GMConnectionFailed status.BridgeStateErrorCode = "gm-connection-failed"
@ -44,6 +45,7 @@ func init() {
GMListenError: "Error polling messages from Google Messages server, the bridge will try to reconnect", GMListenError: "Error polling messages from Google Messages server, the bridge will try to reconnect",
GMFatalError: "Fatal error polling messages from Google Messages server, please re-link the bridge", GMFatalError: "Fatal error polling messages from Google Messages server, please re-link the bridge",
GMUnpaired: "Unpaired from Google Messages, please re-link the connection to continue using SMS/RCS", GMUnpaired: "Unpaired from Google Messages, please re-link the connection to continue using SMS/RCS",
GMUnpaired404: "Unpaired from Google Messages, please re-link the connection to continue using SMS/RCS",
GMBrowserInactive: "Google Messages opened in another browser", GMBrowserInactive: "Google Messages opened in another browser",
GMBrowserInactiveTimeout: "Google Messages disconnected due to timeout", GMBrowserInactiveTimeout: "Google Messages disconnected due to timeout",
GMBrowserInactiveInactivity: "Google Messages disconnected due to inactivity", GMBrowserInactiveInactivity: "Google Messages disconnected due to inactivity",

View file

@ -474,7 +474,7 @@ func (user *User) Connect() bool {
if errors.Is(err, events.ErrRequestedEntityNotFound) { if errors.Is(err, events.ErrRequestedEntityNotFound) {
go user.Logout(status.BridgeState{ go user.Logout(status.BridgeState{
StateEvent: status.StateBadCredentials, StateEvent: status.StateBadCredentials,
Error: GMUnpaired, Error: GMUnpaired404,
Info: map[string]any{ Info: map[string]any{
"go_error": err.Error(), "go_error": err.Error(),
}, },
@ -583,7 +583,7 @@ func (user *User) syncHandleEvent(event any) {
if errors.Is(v.Error, events.ErrRequestedEntityNotFound) { if errors.Is(v.Error, events.ErrRequestedEntityNotFound) {
go user.Logout(status.BridgeState{ go user.Logout(status.BridgeState{
StateEvent: status.StateBadCredentials, StateEvent: status.StateBadCredentials,
Error: GMUnpaired, Error: GMUnpaired404,
Info: map[string]any{ Info: map[string]any{
"go_error": v.Error.Error(), "go_error": v.Error.Error(),
}, },