question

Rob Hayes avatar image
Rob Hayes asked

Invalid EmailAddress/Username/Password PlayFabErrorCodes not handled

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!

Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
madmojoman avatar image
madmojoman answered

I would use the "default" case in the switch to track any unhandled error.Error responses you may run into and log those for updating to get more specific handling of the errors in the future. (instead of another "case <whatever>: ... break;" ... using "default: ... break;" and grabbing the error code for whatever was missed in your regular case situations.

But I believe that the Invalid Input Parameter has to do with the actual input, and is a little different from the other more specific InvalidEmailAddress, InvalidPassword, and InvalidUsername errors. The other three errors are if the input is valid, but then the address/password/username are not.

If I remember correctly the Invalid Input Parameters one can happen when you have strange symbols in the text being sent that stop it from checking on them individually. I don't recall exactly what triggers the other invalids after it passing through that, though. Aside from an obvious issue with email, password, and username, of course.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rob Hayes avatar image Rob Hayes commented ·

This helped a lot, thank you @madmojoman!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.