U++ framework
Do not panic. Ask here before giving up.

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 is currently offline  mirek
Messages: 14290
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

Previous Topic: Development blog canceled, topics moved to "news"
Next Topic: CParser::ReadString inverted default for 'unterminated string' checks
Goto Forum:
  


Current Time: Tue Apr 28 21:19:15 GMT+2 2026

Total time taken to generate the page: 0.00677 seconds