When attempting to add a friend in Cloud Script the request will fail with a CloudScriptAPIRequestError for circumstances where the expectation is to receive a different error code.
So far I've tested adding a friend who is already friends and adding a friend who doesn't exist. For this I'm using FriendTitleDisplayName. Both times I receive CloudScriptAPIRequestError and the handler function in CloudScript stops executing immediately returning the error. I expected that I'd receive errors which indicate UsersAlreadyFriends or AccountNotFound and that the handler function wouldn't break.
When using the same handler function to add a friend who does exist and isn't currently friends with the player there are no errors and the friend addition appears to work.
Answer by Joshua Strunk · Nov 09, 2016 at 07:49 PM
There is certainly a discussion to be had about how CloudScript handles server api errors but as of right now the way you handle this is by using Try Catch statements.
GetFriendsList critical error 3 Answers
RemoveFriend is not always working 2 Answers