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/client.go | |
| parent | ea07a6d7b2df9b09d8e4c796b2416a60ba90144a (diff) | |
FSM: Check unhandled transitions
Diffstat (limited to 'client/client.go')
| -rw-r--r-- | client/client.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/client/client.go b/client/client.go index 103136b..63e4f91 100644 --- a/client/client.go +++ b/client/client.go @@ -73,7 +73,7 @@ func (client *Client) Register( name string, directory string, language string, - stateCallback func(FSMStateID, FSMStateID, interface{}), + stateCallback func(FSMStateID, FSMStateID, interface{}) bool, debug bool, ) error { errorMessage := "failed to register with the GO library" @@ -155,11 +155,15 @@ func (client *Client) Deregister() { // askProfile asks the user for a profile by moving the FSM to the ASK_PROFILE state. func (client *Client) askProfile(chosenServer server.Server) error { + errorMessage := "failed asking for profiles" profiles, profilesErr := server.GetValidProfiles(chosenServer, client.SupportsWireguard) if profilesErr != nil { - return types.NewWrappedError("failed asking for profiles", profilesErr) + return types.NewWrappedError(errorMessage, profilesErr) + } + goTransitionErr := client.FSM.GoTransitionRequired(STATE_ASK_PROFILE, profiles) + if goTransitionErr != nil { + return types.NewWrappedError(errorMessage, goTransitionErr) } - client.FSM.GoTransitionWithData(STATE_ASK_PROFILE, profiles) return nil } |
