summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-01-13 01:07:59 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-01-13 01:07:59 (GMT)
commitef37460d0814879f5022cbb9692f3eaa49d9c8c3 (patch)
treee320dcb31e985ac25130509e4517c8d795593550 /src/declarative
parent6884983aec9afcf71cb34241e453b2edf431a43b (diff)
downloadQt-ef37460d0814879f5022cbb9692f3eaa49d9c8c3.zip
Qt-ef37460d0814879f5022cbb9692f3eaa49d9c8c3.tar.gz
Qt-ef37460d0814879f5022cbb9692f3eaa49d9c8c3.tar.bz2
Give full error message (with line number) on XMLHttpRequest slot failures.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index 5fd14e7..f69f254 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -45,6 +45,7 @@
#include "qmlengine_p.h"
#include "qmlrefcount_p.h"
#include "qmlengine_p.h"
+#include "qmlexpression_p.h"
#include <QtCore/qobject.h>
#include <QtScript/qscriptvalue.h>
@@ -979,6 +980,7 @@ private:
QScriptValue dispatchCallback();
QScriptValue m_callback;
+ void printError(const QScriptValue&);
int m_status;
QString m_statusText;
@@ -1199,8 +1201,7 @@ void QmlXMLHttpRequest::downloadProgress(qint64 bytes)
m_state = HeadersReceived;
fillHeadersList ();
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
bool wasEmpty = m_responseEntityBody.isEmpty();
@@ -1208,8 +1209,7 @@ void QmlXMLHttpRequest::downloadProgress(qint64 bytes)
if (wasEmpty && !m_responseEntityBody.isEmpty()) {
m_state = Loading;
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
}
@@ -1233,16 +1233,14 @@ void QmlXMLHttpRequest::error(QNetworkReply::NetworkError error)
error == QNetworkReply::ContentReSendError) {
m_state = Loading;
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
} else {
m_errorFlag = true;
}
m_state = Done;
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
void QmlXMLHttpRequest::finished()
@@ -1258,21 +1256,18 @@ void QmlXMLHttpRequest::finished()
m_state = HeadersReceived;
fillHeadersList ();
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
m_responseEntityBody.append(m_network->readAll());
destroyNetwork();
if (m_state < Loading) {
m_state = Loading;
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
m_state = Done;
QScriptValue cbv = dispatchCallback();
- if (cbv.isError())
- qWarning().nospace() << qPrintable(cbv.toString());
+ if (cbv.isError()) printError(cbv);
}
@@ -1286,6 +1281,13 @@ QScriptValue QmlXMLHttpRequest::dispatchCallback()
return m_callback.call();
}
+void QmlXMLHttpRequest::printError(const QScriptValue& sv)
+{
+ QmlError error;
+ QmlExpressionPrivate::exceptionToError(sv.engine(), error);
+ qWarning().nospace() << qPrintable(error.toString());
+}
+
void QmlXMLHttpRequest::destroyNetwork()
{
if (m_network) {