History

add error log debug for script fail

Stephen Birarda committed 11 years ago

Commit e4626171 parent 6419a141 file · +8 −5Browse files

Showing the changes to libraries/script-engine/src/ScriptCache.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptCache.cpp+8−5
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <QCoreApplication>
1313 #include <QEventLoop>
1414 #include <QNetworkAccessManager>
15+#include <QNetworkConfiguration>
1516 #include <QNetworkReply>
1617 #include <QObject>
1718
@@ -35,7 +36,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 17 unmodified lines
3536 isPending = true;
3637 bool alreadyWaiting = _scriptUsers.contains(url);
3738 _scriptUsers.insert(url, scriptUser);
38−
39+
3940 if (alreadyWaiting) {
4041 qCDebug(scriptengine) << "Already downloading script at:" << url.toString();
4142 } else {
@@ -43,7 +44,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 1 unmodified line
4344 QNetworkRequest networkRequest = QNetworkRequest(url);
4445 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
4546
46− qCDebug(scriptengine) << "Downloading script at:" << url.toString();
47+ qCDebug(scriptengine) << "Downloading script at" << url.toString();
4748 QNetworkReply* reply = networkAccessManager.get(networkRequest);
4849 connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
4950 }
@@ -56,7 +57,7 @@ void ScriptCache::scriptDownloaded() { · 6 unmodified lines
5657 QUrl url = reply->url();
5758 QList<ScriptUser*> scriptUsers = _scriptUsers.values(url);
5859 _scriptUsers.remove(url);
59−
60+
6061 if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
6162 _scriptCache[url] = reply->readAll();
6263 qCDebug(scriptengine) << "Done downloading script at:" << url.toString();
@@ -65,7 +66,9 @@ void ScriptCache::scriptDownloaded() { · 2 unmodified lines
6566 user->scriptContentsAvailable(url, _scriptCache[url]);
6667 }
6768 } else {
68− qCDebug(scriptengine) << "ERROR Loading file:" << reply->url().toString();
69+ qCWarning(scriptengine) << "Error loading script from URL " << reply->url().toString()
70+ << "- HTTP status code is" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
71+ << "and error from QNetworkReply is" << reply->errorString();
6972 foreach(ScriptUser* user, scriptUsers) {
7073 user->errorInLoadingScript(url);
7174 }
@@ -73,4 +76,4 @@ void ScriptCache::scriptDownloaded() { · 1 unmodified line
7376 reply->deleteLater();
7477 }
7578
76−
79+