mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Throw error when parsed JSON is invalid
Without this error detection, the malformed bootstrap.json stayed undetected. Hence, the old VATSIM FSD HTTP URL was used.
This commit is contained in:
@@ -71,5 +71,5 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"wasLoadedFromFile": false,
|
||||
"wasLoadedFromFile": false
|
||||
}
|
||||
|
||||
@@ -411,7 +411,14 @@ namespace BlackMisc::Json
|
||||
QJsonObject jsonObjectFromString(const QString &json, bool acceptCacheFormat)
|
||||
{
|
||||
if (json.isEmpty()) { return QJsonObject(); }
|
||||
const QJsonDocument jsonDoc(QJsonDocument::fromJson(json.toUtf8()));
|
||||
|
||||
QJsonParseError error {};
|
||||
const QJsonDocument jsonDoc(QJsonDocument::fromJson(json.toUtf8(), &error));
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
{
|
||||
throw CJsonException(error.errorString());
|
||||
}
|
||||
|
||||
return acceptCacheFormat ? Json::unwrapCache(jsonDoc.object()) : jsonDoc.object();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user