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.