Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pass the resource URL to the resourceError handler.

  • Loading branch information...
commit 6d81933941ec7e8e22a965fdbd9824a3ac86136a 1 parent 797b47a
@Vitallium Vitallium authored committed
View
11 src/networkaccessmanager.cpp
@@ -318,13 +318,20 @@ void NetworkAccessManager::handleNetworkError()
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
qDebug() << "Network - Resource request error:"
<< reply->error()
- << "(" << reply->errorString() << ")";
+ << "(" << reply->errorString() << ")"
+ << "URL:" << reply->url().toString();
m_ids.remove(reply);
if (m_started.contains(reply))
m_started.remove(reply);
- emit resourceError(reply->error(), reply->errorString());
+ QVariantMap data;
+ data["url"] = reply->url().toString();
+ data["errorCode"] = reply->error();
+ data["errorString"] = reply->errorString();
+
+ emit resourceError(data);
+
reply->deleteLater();
}
View
2  src/networkaccessmanager.h
@@ -79,7 +79,7 @@ class NetworkAccessManager : public QNetworkAccessManager
signals:
void resourceRequested(const QVariant& data, QObject *);
void resourceReceived(const QVariant& data);
- void resourceError(const QVariant& errorCode, const QVariant& errorString);
+ void resourceError(const QVariant& data);
private slots:
void handleStarted();
View
4 src/webpage.cpp
@@ -372,8 +372,8 @@ WebPage::WebPage(QObject *parent, const QUrl &baseUrl)
SIGNAL(resourceRequested(QVariant, QObject *)));
connect(m_networkAccessManager, SIGNAL(resourceReceived(QVariant)),
SIGNAL(resourceReceived(QVariant)));
- connect(m_networkAccessManager, SIGNAL(resourceError(QVariant, QVariant)),
- SIGNAL(resourceError(QVariant, QVariant)));
+ connect(m_networkAccessManager, SIGNAL(resourceError(QVariant)),
+ SIGNAL(resourceError(QVariant)));
m_customWebPage->setViewportSize(QSize(400, 300));
}
View
2  src/webpage.h
@@ -463,7 +463,7 @@ public slots:
void javaScriptErrorSent(const QString &msg, const QString &stack);
void resourceRequested(const QVariant &requestData, QObject *request);
void resourceReceived(const QVariant &resource);
- void resourceError(const QVariant &errorCode, const QVariant &errorString);
+ void resourceError(const QVariant &errorData);
void urlChanged(const QUrl &url);
void navigationRequested(const QUrl &url, const QString &navigationType, bool navigationLocked, bool isMainFrame);
void rawPageCreated(QObject *page);
View
7 test/webpage-spec.js
@@ -1063,9 +1063,10 @@ describe("WebPage object", function() {
var handled = false;
runs(function() {
- page.onResourceError = function(errorCode, errorString) {
- expect(errorCode).toEqual(203);
- expect(errorString).toContain('notExistResource.png - server replied: Not Found');
+ page.onResourceError = function(errorData) {
+ expect(errorData['url']).toEqual('http://localhost:12345/notExistResource.png');
+ expect(errorData['errorCode']).toEqual(203);
+ expect(errorData['errorString']).toContain('notExistResource.png - server replied: Not Found');
handled = true;
};
Please sign in to comment.
Something went wrong with that request. Please try again.