I read lots of the old threads about Unexpected Type Error and how Properties.getValue can return null. My problem resembles that, but I still can't figure out what is the problem.
My code is:
function getConfig(key as PropertyKeyType) as PropertyValueType? { var val; // this is the line I get the error according to ERA try { val = Properties.getValue(key); } catch (e) { logRelease(key + ":" + e.getErrorMessage()); val = null; } return val; }
And this is the error from ERA:
Error Name: Unexpected Type Error Occurrences: 7 First Occurrence: 2024-01-17 Last Occurrence: 2024-01-22 Devices: vívoactive® 4S: 7.80 App Versions: 2.3.1 Languages: pol Backtrace: Config.getConfig:18 Config.getConfigNumber:93 MyApp.onStop:122
So what I know is that the error is in getConfig. And before you point me to the best practices to check for null and type, all that code is in getConfigNumber().
Because the call comes from MyApp.onStop:122, I even know that key = "i" so I believe even the
key + ":" + e.getErrorMessage()
can't be the problem (all 3 are strings)
However I can't understand then what can be the problem in the last line that makes sense:
val = Properties.getValue(key);
the value of the i property is supposed to be a number, but even if it isn't (and that would be taken care of in getConfigNumber) whatever the type of the property is, including null, I can't understand how the above line (or any other line in getConfig() can cause an Unexpected Type Error.