Merge lp:~mikemc/ubuntuone-credentials/improve-warnings into lp:ubuntuone-credentials

Proposed by Mike McCracken
Status: Merged
Approved by: Mike McCracken
Approved revision: 75
Merged at revision: 74
Proposed branch: lp:~mikemc/ubuntuone-credentials/improve-warnings
Merge into: lp:ubuntuone-credentials
Diff against target: 48 lines (+15/-7)
2 files modified
libubuntuoneauth/identityprovider.cpp (+2/-2)
libubuntuoneauth/network.cpp (+13/-5)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-credentials/improve-warnings
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
dobey (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+191842@code.launchpad.net

Commit message

- Improve logged warnings about token creation errors and JSON parsing (LP: #1241250, LP: #1241259)

Description of the change

- Improve logged warnings about token creation errors and JSON parsing (LP: #1241250, LP: #1241259)

Difficult to test without a broken test server to send broken replies.
Should be clear what's going on, though.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntuoneauth/identityprovider.cpp'
2--- libubuntuoneauth/identityprovider.cpp 2013-07-02 18:44:51 +0000
3+++ libubuntuoneauth/identityprovider.cpp 2013-10-18 17:23:26 +0000
4@@ -87,8 +87,8 @@
5
6 }else{
7
8- qWarning("Error occurred creating token: %d (%s)",
9- error.code(), error.message().toUtf8().data());
10+ qCritical("Error occurred creating token: %d (%s)",
11+ error.code(), error.message().toUtf8().data());
12
13 emit ErrorOccurred(error);
14 }
15
16=== modified file 'libubuntuoneauth/network.cpp'
17--- libubuntuoneauth/network.cpp 2013-10-03 22:48:26 +0000
18+++ libubuntuoneauth/network.cpp 2013-10-18 17:23:26 +0000
19@@ -69,16 +69,24 @@
20 return;
21 }
22
23- QJsonDocument document = QJsonDocument::fromJson(payload);
24-
25- if (document.isEmpty()) {
26- QString errmsg = QString("Network::OnReply received empty document");
27+ QJsonParseError jsonParseError;
28+ QJsonDocument document = QJsonDocument::fromJson(payload, &jsonParseError);
29+
30+ if(jsonParseError.error != QJsonParseError::NoError){
31+ QString errmsg = QString ("Network::OnReply: error parsing JSON reply: ");
32+ errmsg += jsonParseError.errorString();
33+ emit ErrorOccurred(ErrorResponse(0, NO_HTTP_REASON, LOGIN_FAILED, errmsg));
34+ return;
35+ }
36+
37+ if (document.isEmpty() || document.isNull()) {
38+ QString errmsg = QString("Network::OnReply: received empty or Null document");
39 emit ErrorOccurred(ErrorResponse(0, NO_HTTP_REASON, LOGIN_FAILED, errmsg));
40 return;
41 }
42
43 if (!document.isObject()) {
44- QString errmsg = QString("Network::OnReply received invalid QJsonDocument");
45+ QString errmsg = QString("Network::OnReply: received JSON document that isn't an object.");
46 emit ErrorOccurred(ErrorResponse(0, NO_HTTP_REASON, LOGIN_FAILED, errmsg));
47 return;
48 }

Subscribers

People subscribed via source and target branches

to all changes: