From 4a4b3f0a1c008e35a4492b7fd05176d1822c7232 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 22 Nov 2022 16:14:06 +0100 Subject: FSM: Check unhandled transitions --- client/client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'client/client.go') 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 } -- cgit v1.2.3