diff options
author | abcd <amos.choy@nokia.com> | 2012-06-26 17:48:14 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-05 06:26:13 +0200 |
commit | b259be3e53f534cc4355f1fe7957f361c08b9890 (patch) | |
tree | 634941ac8ed3431e42bea7e61c46a7fcf38f4cee /src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp | |
parent | 3e49bbe8a67f2b5524f7ac8aa2bf99a2ba2ec5ce (diff) | |
download | qtlocation-b259be3e53f534cc4355f1fe7957f361c08b9890.tar.gz |
Refactor error handling in nokia plugin for search suggestions
Change-Id: I022ccad6a1d53ec0f3da14e1ef8fe0e2b27e0687
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp')
-rw-r--r-- | src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp index 37820e3a..a25a0332 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp @@ -65,8 +65,6 @@ QPlaceSearchSuggestionReplyImpl::QPlaceSearchSuggestionReplyImpl(QNetworkReply * m_reply->setParent(this); connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); - connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), - this, SLOT(replyError(QNetworkReply::NetworkError))); } QPlaceSearchSuggestionReplyImpl::~QPlaceSearchSuggestionReplyImpl() @@ -90,6 +88,17 @@ void QPlaceSearchSuggestionReplyImpl::setError(QPlaceReply::Error error_, void QPlaceSearchSuggestionReplyImpl::replyFinished() { + if (m_reply->error() != QNetworkReply::NoError) { + switch (m_reply->error()) { + case QNetworkReply::OperationCanceledError: + setError(CancelError, "Request canceled."); + break; + default: + setError(CommunicationError, "Network error."); + } + return; + } + QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); @@ -117,15 +126,4 @@ void QPlaceSearchSuggestionReplyImpl::replyFinished() emit finished(); } -void QPlaceSearchSuggestionReplyImpl::replyError(QNetworkReply::NetworkError error) -{ - switch (error) { - case QNetworkReply::OperationCanceledError: - setError(CancelError, "Request canceled."); - break; - default: - setError(CommunicationError, "Network error."); - } -} - QT_END_NAMESPACE |