question

John Peterson avatar image
John Peterson asked

How to manage server API error codes with TypeScript?

Dear PlayFab community,

I'm wondering how to account for potential error codes returned from the server API when developing CloudScript code with TypeScript. For example, I want to capture the InvalidDropTable error code from the GetRandomResultTables() call:

https://api.playfab.com/documentation/server/method/GetRandomResultTables#error-codes

I see in the documentation that the response has a "code" and "status" fields. However, the TypeScript typings do not seem to have those properties defined. Is this an oversight of the typings? Should all *Result types be extending a base Result that has those properties? Is there an example of how I might be able to obtain this error information?

Thanks in advance!

apisCloudScript
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

·
brendan avatar image
brendan answered

Thanks, that's a fair point - we didn't include that, as failed API calls cause an exception to be thrown in Cloud Script. But if you're using try/catch, you might still want to work with those response values in the script directly. I've opened a work item for the tools team to look at adding that.

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.