diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-22 16:14:06 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-23 16:16:09 +0100 |
| commit | 4a4b3f0a1c008e35a4492b7fd05176d1822c7232 (patch) | |
| tree | 287ac69b6f89524282d4e2cbc85c6d8030285c88 /client/server.go | |
| parent | ea07a6d7b2df9b09d8e4c796b2416a60ba90144a (diff) | |
FSM: Check unhandled transitions
Diffstat (limited to 'client/server.go')
| -rw-r--r-- | client/server.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/client/server.go b/client/server.go index 3bcecc6..d22dc65 100644 --- a/client/server.go +++ b/client/server.go @@ -479,16 +479,20 @@ func (client *Client) GetConfigCustomServer(url string, preferTCP bool) (string, // askSecureLocation asks the user to choose a Secure Internet location by moving the FSM to the STATE_ASK_LOCATION state. func (client *Client) askSecureLocation() error { + errorMessage := "failed settings secure location" locations := client.Discovery.GetSecureLocationList() // Ask for the location in the callback - client.FSM.GoTransitionWithData(STATE_ASK_LOCATION, locations) + goTransitionErr := client.FSM.GoTransitionRequired(STATE_ASK_LOCATION, locations) + if goTransitionErr != nil { + return types.NewWrappedError(errorMessage, goTransitionErr) + } // The state has changed, meaning setting the secure location was not successful if client.FSM.Current != STATE_ASK_LOCATION { // TODO: maybe a custom type for this errors.new? return types.NewWrappedError( - "failed setting secure location", + errorMessage, errors.New("failed loading secure location"), ) } @@ -579,7 +583,10 @@ func (client *Client) ensureLogin(chosenServer server.Server) error { if server.NeedsRelogin(chosenServer) { url, urlErr := server.GetOAuthURL(chosenServer, client.Name) - client.FSM.GoTransitionWithData(STATE_OAUTH_STARTED, url) + goTransitionErr := client.FSM.GoTransitionRequired(STATE_OAUTH_STARTED, url) + if goTransitionErr != nil { + return types.NewWrappedError(errorMessage, goTransitionErr) + } if urlErr != nil { client.goBackInternal() |
