Commit 61e7ac7c authored by Lars Knoll's avatar Lars Knoll Committed by Oswald Buddenhagen

Improve error reporting when parsing JSON files

At least report the error string and the file offset where
the error happened.

Change-Id: Iaa1733593b8af2a7a52b67c0f495731f045d2c11
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
(cherry picked from qtbase/34c24ceb1ffce964c9f139d84b6b271bd2e45c33)
Reviewed-by: Jake Petroules's avatarJake Petroules <jake.petroules@qt.io>
Reviewed-by: default avatarRobert Loehning <robert.loehning@qt.io>
parent 962d1122
......@@ -390,11 +390,16 @@ static void addJsonValue(const QJsonValue &value, const QString &keyPrefix, ProV
}
}
static QMakeEvaluator::VisitReturn parseJsonInto(const QByteArray &json, const QString &into, ProValueMap *value)
QMakeEvaluator::VisitReturn QMakeEvaluator::parseJsonInto(const QByteArray &json, const QString &into, ProValueMap *value)
{
QJsonDocument document = QJsonDocument::fromJson(json);
if (document.isNull())
QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(json, &error);
if (document.isNull()) {
if (error.error != QJsonParseError::NoError)
evalError(fL1S("Error parsing json at offset %1: %2")
.arg(error.offset).arg(error.errorString()));
return QMakeEvaluator::ReturnFalse;
}
QString currentKey = into + QLatin1Char('.');
......
......@@ -229,6 +229,7 @@ public:
bool getMemberArgs(const ProKey &name, int srclen, const ProStringList &args,
int *start, int *end);
VisitReturn parseJsonInto(const QByteArray &json, const QString &into, ProValueMap *value);
VisitReturn writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode,
bool exe, const QString &contents);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment