mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
refs #815 Catch and handle CJsonException when calling convertFromJson.
This commit is contained in:
@@ -413,7 +413,15 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
CFlightPlan fp;
|
||||
fp.convertFromJson(json);
|
||||
try
|
||||
{
|
||||
fp.convertFromJson(json);
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
m = ex.toStatusMessage(this, "Parse error in " + fileName);
|
||||
break;
|
||||
}
|
||||
this->fillWithFlightPlanData(fp);
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -124,7 +124,16 @@ namespace BlackGui
|
||||
CLogMessage(this).validationError("Parse error: %1") << jsonError.errorString();
|
||||
return;
|
||||
}
|
||||
parts.convertFromJson(jsonDoc.object());
|
||||
|
||||
try
|
||||
{
|
||||
parts.convertFromJson(jsonDoc.object());
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
ex.toLogMessage(this, "Parse error");
|
||||
return;
|
||||
}
|
||||
partsToGui(parts);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -149,7 +149,8 @@ namespace BlackGui
|
||||
if (typeName.isEmpty() || typeId == QMetaType::UnknownType) { return CVariant(); }
|
||||
|
||||
CVariant valueVariant;
|
||||
valueVariant.convertFromJson(jsonObj);
|
||||
const CStatusMessage status = valueVariant.convertFromJsonNoThrow(jsonObj, {}, {});
|
||||
if (status.isFailure()) { return CVariant(); }
|
||||
return valueVariant;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user