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
12#include <QCoreApplication>12#include <QCoreApplication>
13#include <QEventLoop>13#include <QEventLoop>
14#include <QNetworkAccessManager>14#include <QNetworkAccessManager>
15#include <QNetworkConfiguration>
15#include <QNetworkReply>16#include <QNetworkReply>
16#include <QObject>17#include <QObject>
17 18
@@ -35,7 +36,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 17 unmodified lines
35 isPending = true;36 isPending = true;
36 bool alreadyWaiting = _scriptUsers.contains(url);37 bool alreadyWaiting = _scriptUsers.contains(url);
37 _scriptUsers.insert(url, scriptUser);38 _scriptUsers.insert(url, scriptUser);
38 39
39 if (alreadyWaiting) {40 if (alreadyWaiting) {
40 qCDebug(scriptengine) << "Already downloading script at:" << url.toString();41 qCDebug(scriptengine) << "Already downloading script at:" << url.toString();
41 } else {42 } else {
@@ -43,7 +44,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 1 unmodified line
43 QNetworkRequest networkRequest = QNetworkRequest(url);44 QNetworkRequest networkRequest = QNetworkRequest(url);
44 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);45 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
45 46
46 qCDebug(scriptengine) << "Downloading script at:" << url.toString();47 qCDebug(scriptengine) << "Downloading script at" << url.toString();
47 QNetworkReply* reply = networkAccessManager.get(networkRequest);48 QNetworkReply* reply = networkAccessManager.get(networkRequest);
48 connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);49 connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
49 }50 }
@@ -56,7 +57,7 @@ void ScriptCache::scriptDownloaded() { · 6 unmodified lines
56 QUrl url = reply->url();57 QUrl url = reply->url();
57 QList<ScriptUser*> scriptUsers = _scriptUsers.values(url);58 QList<ScriptUser*> scriptUsers = _scriptUsers.values(url);
58 _scriptUsers.remove(url);59 _scriptUsers.remove(url);
59 60
60 if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {61 if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
61 _scriptCache[url] = reply->readAll();62 _scriptCache[url] = reply->readAll();
62 qCDebug(scriptengine) << "Done downloading script at:" << url.toString();63 qCDebug(scriptengine) << "Done downloading script at:" << url.toString();
@@ -65,7 +66,9 @@ void ScriptCache::scriptDownloaded() { · 2 unmodified lines
65 user->scriptContentsAvailable(url, _scriptCache[url]);66 user->scriptContentsAvailable(url, _scriptCache[url]);
66 }67 }
67 } else {68 } 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();
69 foreach(ScriptUser* user, scriptUsers) {72 foreach(ScriptUser* user, scriptUsers) {
70 user->errorInLoadingScript(url);73 user->errorInLoadingScript(url);
71 }74 }
@@ -73,4 +76,4 @@ void ScriptCache::scriptDownloaded() { · 1 unmodified line
73 reply->deleteLater();76 reply->deleteLater();
74}77}
75 78
76 79