question

Matt avatar image
Matt asked

ExecuteFunction Error Handling

Hey folks,

I'm just considering some of the error handling I need to do for my game, and I noticed on this page that the errors returned don't include anything about sessions expiring. The last game I made, using the legacy cloudscripting, I had to handle the scenario where the player's login had expired and I had to log them back in before continuing to make calls.

Is that not a possible error using the Azure functions? If it is possible, where do I check to see that error? From what I can tell, the errors listed are mostly just execution errors of the cloudscript.

Thanks!

-Matt

10 |1200

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

Made Wang avatar image
Made Wang answered

I'm sorry I misunderstood your description at the beginning. You want to determine whether the current user's session ticket has expired when the client calls the API, instead of handling the error message in an Azure Function,right?

To clarify, ExecuteFunction belongs to entity API, it uses EntityToken for authentication, so when EntityToken expires, you will get error like below. Also, you can refresh entityToken by re-login or call GetEntityToken.

{
    "code": 401,
    "status": "Unauthorized",
    "error": "EntityTokenExpired",
    "errorCode": 1336,
    "errorMessage": "EntityTokenExpired"
}
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.

Matt avatar image Matt commented ·

Ah yes, that's exactly what I was looking for. I didn't see it on the ExecuteFunction page, so wasn't sure where I could look up the errors that could occur. Thanks!

0 Likes 0 ·
Made Wang avatar image
Made Wang answered

You can view the error message in the log stream in the Azure portal, or you can add a try/catch in the Azure Function to capture the error message and return it as a result.

Currently PlayFab PlayStream Event doesn't show detailed error message for Cloud Script in Azure Function, please feel free to post a feature request if this is what you need.

4 comments
10 |1200

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

Matt avatar image Matt commented ·

I don't need an error message, I just need to know which errors can be triggered from ExecuteFunction. Specifically, is one of the errors related to a player simply needing to relog back into PlayFab?

0 Likes 0 ·
Matt avatar image Matt commented ·

Just to be clear, it's not practical for me to set everything up, and then attempt to trigger every error so I can see which ones exist or not for the function. Cleary this type of information needs to be provided by the authors of the API. You can't expect someone to exhaustively test every scenario imaginable to determine the potential errors.

The reason I ask about the sign in expiring error is because I'd specifically log the player back in to refresh their session ticket. I had to do this on my last game, as rare as it was, so I need to know if that's also a possibility.

0 Likes 0 ·
Made Wang avatar image Made Wang Matt commented ·

ExecuteFunction can currently only return its own error, not the error information in the function it calls. If you need to return error information in the form of log like legacy Cloud Script, then please post a feature request to let us know you need it.

Also, session tickets are valid for 24 hours, maybe you can try manually calculating the time since last login.

0 Likes 0 ·
Matt avatar image Matt Made Wang commented ·

I see, so those errors are strictly for that function. Am I to assume that function couldn't succeed if the ticket expired, right? If that's the case, then at least some error would occur...I can just globally handle it that way I guess.

It doesn't seem right for me to manually track session tickets, that seems like a hack that I'm kind of surprised isn't more elegantly handled. It used to be 2 weeks from what I remember as well, but that's neither here nor there.

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.