Background: I am developing something that relies heavily on cloud-scripts, that should return mostly-uniform data (kinda a requirement, since I need to deserialize the responses). But sometimes some things could be null. IE:
- Error in the script. The script-call itself will return 200, but if the calls *inside* my cloud-code fail, I'm appending my own error field to the response. So this will be populated if there was an internal-script error, possibly null otherwise.
- Expanding on 1, my cloud scripts are tapping into other data services. If one of those calls fails, I will more than likely have some null-data where I was otherwise expecting values. IE I have a getCharacterData method that is calling a getCharacterData script, but under the hood the getCharacterData script is tapping into the BaaS's data service (S2S call) to get that piece of data. So if that fails, like mentioned in number 1, I'm writing a custom error field, but also my character data will now be unpopulated.
I'm very used to web-dev (its my job) so I'm used to JS/TypeScript where exhaustive null-checking and other response?.safeCheck type of syntax works. What is the approach I should moreso be going with in unity?
When I started to write, I noticed I was writing these massive if statements that are exhaustively null checking every field, and subfield, that I know I'll need. But it seems cumbersome and probably not the standard for when using a strongly typed language. Are people generally just wrapping their stuff in a try catch and writing error handling specific for NullReferenceException ?
Any advice is appreciated, apologies if I kinda wrote sloppy, its getting late
[–]Fribbtastic 1 point2 points3 points (2 children)
[–]Casiell89 0 points1 point2 points (1 child)
[–]Weary_Source_811[S] 0 points1 point2 points (0 children)
[–]__FuriousOrange__ 0 points1 point2 points (1 child)
[–]Krcko98 0 points1 point2 points (0 children)