I'm attempting to display individual popups for each possible error thrown when the player is registering a new account. My code looks like this:
private void OnRegisterFailure(PlayFabError error) { switch (error.Error) { case PlayFabErrorCode.AccountAlreadyLinked: //Handle Account Already Linked Error break; case PlayFabErrorCode.EmailAddressNotAvailable: //Handle Email Address Not Available Error break; case PlayFabErrorCode.InvalidEmailAddress: //Handle Invalid Email Address Error break; case PlayFabErrorCode.InvalidPassword: //Handle Invalid Password Error break; case PlayFabErrorCode.InvalidUsername: //Handle Invalid Username Error break; case PlayFabErrorCode.UsernameNotAvailable: //Handle Username Not Available Error break; }
The handling for AccountAlreadyLinked, EmailAddressNotAvailable, and UsernameNotAvailable all work perfectly. However, the code inside the cases for InvalidEmailAddress, InvalidPassword, and InvalidUsername never gets executed when that respective error occurs.
I further tested and found that the following code will work to address all 3 invalid entry cases:
private void OnRegisterFailure(PlayFabError error) { string errorMessage = "Invalid input parameters"; if (error.ErrorMessage == errorMessage) { //Handle invalid paramters error } }
I know that errorCode and errorMessage aren't the same, but does this mean that all 3 cases are throwing the same "Invalid input parameters" error, and not individual errors depending on which parameter is invalid?
I could potentially solve the problem by removing the 3 invalid parameter cases from the switch statement and include the if statement to handle them. However, I would prefer to include all cases in the switch statement and have individual handles for each of the errors.
Is there a reason the invalid EmailAddress/Password/Username codes aren't working in the switch statement? Any help is appreciated!