summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKevin Simons <kevin.simons@nokia.com>2012-04-28 17:58:22 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-30 21:25:04 +0200
commitb9afea167aaf98f9fadb2b73b129d6631399217e (patch)
tree13d167c47c62ba8a2f3d9bbb4c45c579b436cb32 /tools
parent7428ccfd397255080e33ffd3c5325d794dae0f9c (diff)
Improve error output when loading .json files with -load
Change-Id: Ib490ef0f6cfb3b1a72d73b920fb8e1f335345420 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/jsondb-client/client.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/jsondb-client/client.cpp b/tools/jsondb-client/client.cpp
index ccb9d43a..60103b15 100644
--- a/tools/jsondb-client/client.cpp
+++ b/tools/jsondb-client/client.cpp
@@ -671,9 +671,16 @@ void Client::loadJsonFile(const QString &jsonFile)
}
json.open(QFile::ReadOnly);
- QJsonDocument doc = QJsonDocument::fromJson(json.readAll());
+ QJsonParseError error;
+ QJsonDocument doc = QJsonDocument::fromJson(json.readAll(), &error);
json.close();
+ if (error.error != QJsonParseError::NoError) {
+ qDebug() << "Unable to parse file:" << error.errorString();
+ fileLoadError();
+ return;
+ }
+
QList<QJsonObject> objects;
if (doc.isArray()) {
QJsonArray objectArray = doc.array();
@@ -691,6 +698,8 @@ void Client::loadJsonFile(const QString &jsonFile)
connect(write, SIGNAL(finished()), this, SLOT(fileLoadSuccess()));
connect(write, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
this, SLOT(fileLoadError()));
+ connect(write, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
+ this, SLOT(onRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
mConnection->send(write);
}