Home » Community » U++ community news and announcements » Invalid Value conversions now throws (instead of undefined behaviour)
Invalid Value conversions now throws (instead of undefined behaviour) [message #42877] |
Sat, 12 April 2014 19:41 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
So far, trying to convert Value to incompatible type failed ASSERT in debug and was undefined in release.
This was fine for a long time, but e.g. with JSON parsed into Value, it is sort of more problematic, as then in theory all Values should have been tested for the right type before assigning them (as you cannot never trust external .json data to provide correct types).
That is why from now, invalid conversion results in exception ValueTypeError and we can now safely write:
try {
Value v = ParseJSON(...);
String h = v["foo"];
}
catch(ValueTypeError) {
// JSON is invalid
}
Mirek
[Updated on: Sat, 12 April 2014 19:45] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 19 23:58:38 CEST 2024
Total time taken to generate the page: 0.03205 seconds
|