summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2016-05-19 15:40:55 +0200
committerLars Knoll <lars.knoll@qt.io>2016-06-17 16:11:11 +0000
commit34c24ceb1ffce964c9f139d84b6b271bd2e45c33 (patch)
tree7cc3887453c5dec0320da648f1b48225ea4b7011 /qmake
parenta11ced49810d5b454876f6ea201b89ac3734d3fe (diff)
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: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/library/qmakebuiltins.cpp11
-rw-r--r--qmake/library/qmakeevaluator.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp
index 6f93b655b4..de58469a58 100644
--- a/qmake/library/qmakebuiltins.cpp
+++ b/qmake/library/qmakebuiltins.cpp
@@ -389,11 +389,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('.');
diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h
index 7b911e7911..ab13b24645 100644
--- a/qmake/library/qmakeevaluator.h
+++ b/qmake/library/qmakeevaluator.h
@@ -234,6 +234,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);