question

keatonschwartz avatar image
keatonschwartz asked

server.AddFriend not throwing error on invavlie PlayFabID

I am currently using the cloudscript below to send friend requests.

handlers.SendFriendRequest = function (args, context) {
        server.AddFriend({
            PlayFabId: currentPlayerId,
            FriendPlayFabId: args.FriendPlayFabId
        });
    
        server.SetFriendTags({
            PlayFabId: currentPlayerId,
            FriendPlayFabId: args.FriendPlayFabId,
            Tags: ["requestee"]
        });
    
        server.AddFriend({
            PlayFabId: args.FriendPlayFabId,
            FriendPlayFabId: currentPlayerId
        });
    
        server.SetFriendTags({
            PlayFabId: args.FriendPlayFabId,
            FriendPlayFabId: currentPlayerId,
            Tags: ["requester"]
        });

};

I would like to receive some sort of error if the args.FriendPlayFabId is invalid so that I can alert the user. How can I do this? I don't currently get any errors back from the ExecuteCloudScriptResult when inputting an invalid playfab id.

CloudScriptFriends
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

·
Made Wang avatar image
Made Wang answered

[Edited]You can add the following code to the success callback of calling ExecuteCloudScript to return some error message.

if(result.Error!=null)
            {
                foreach (var log in result.Logs)
                {
                    if(log.Level=="Error")
                    {
                        Debug.LogError(log.Data);
                    }
                }
            }

10 |1200

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

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.