ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #00577
[Merge] lp:~mzanetti/reminders-app/improve-error-handling into lp:reminders-app
Michael Zanetti has proposed merging lp:~mzanetti/reminders-app/improve-error-handling into lp:reminders-app with lp:~mzanetti/reminders-app/two-job-queues as a prerequisite.
Commit message:
improve some error handling
* Rate limit exceeded
* Upload quota exceeded
* Authentication expired
Requested reviews:
Ubuntu Reminders app developers (reminders-app-dev)
For more details, see:
https://code.launchpad.net/~mzanetti/reminders-app/improve-error-handling/+merge/252227
--
Your team Ubuntu Reminders app developers is requested to review the proposed merge of lp:~mzanetti/reminders-app/improve-error-handling into lp:reminders-app.
=== modified file 'src/app/qml/components/StatusBar.qml'
--- src/app/qml/components/StatusBar.qml 2015-03-04 00:23:45 +0000
+++ src/app/qml/components/StatusBar.qml 2015-03-08 21:30:59 +0000
@@ -38,6 +38,7 @@
id: label
width: parent.width - x
wrapMode: Text.WordWrap
+ anchors.verticalCenter: parent.verticalCenter
}
}
}
=== modified file 'src/libqtevernote/evernoteconnection.cpp'
--- src/libqtevernote/evernoteconnection.cpp 2015-03-08 21:30:59 +0000
+++ src/libqtevernote/evernoteconnection.cpp 2015-03-08 21:30:59 +0000
@@ -38,6 +38,7 @@
#include <Errors_types.h>
#include <QUrl>
+#include <QTime>
#include <libintl.h>
@@ -65,6 +66,9 @@
m_userStoreHttpClient(0)
{
qRegisterMetaType<EvernoteConnection::ErrorCode>("EvernoteConnection::ErrorCode");
+
+ m_reconnectTimer.setSingleShot(true);
+ connect(&m_reconnectTimer, &QTimer::timeout, this, &EvernoteConnection::connectToEvernote);
}
void EvernoteConnection::setupUserStore()
@@ -148,6 +152,10 @@
void EvernoteConnection::disconnectFromEvernote()
{
qCDebug(dcConnection) << "Disconnecting from Evernote.";
+
+ m_errorMessage.clear();
+ emit errorChanged();
+
if (!isConnected()) {
qCWarning(dcConnection()) << "Not connected. Can't disconnect.";
return;
@@ -314,6 +322,36 @@
emit errorChanged();
return false;
}
+ } catch (const evernote::edam::EDAMUserException &e) {
+ qCWarning(dcConnection) << "EDAMUserException getting note store path:" << e.what() << "EDAM Error Code:" << e.errorCode;
+ switch (e.errorCode) {
+ case evernote::edam::EDAMErrorCode::AUTH_EXPIRED:
+ m_errorMessage = gettext("Authentication for Evernote server expired. Please renew login information in the accounts settings.");
+ break;
+ default:
+ m_errorMessage = QString(gettext("Unknown error connecting to Evernote: %1")).arg(e.errorCode);
+ break;
+ }
+ emit errorChanged();
+ return false;
+ } catch (const evernote::edam::EDAMSystemException &e) {
+ qCWarning(dcConnection) << "EDAMSystemException getting note store path:" << e.what() << e.errorCode;
+ switch (e.errorCode) {
+ case evernote::edam::EDAMErrorCode::RATE_LIMIT_REACHED:
+ m_errorMessage = gettext("Error connecting to Evernote: Rate limit exceeded. Please try again later.");
+ m_reconnectTimer.stop();
+ m_reconnectTimer.start(e.rateLimitDuration * 1000);
+ {
+ QTime time = QTime::fromMSecsSinceStartOfDay(e.rateLimitDuration * 1000);
+ qCDebug(dcConnection) << "Cannot connect. Rate limit exceeded. Reconnecting in" << time.toString("mm:ss");
+ }
+ break;
+ default:
+ m_errorMessage = gettext("Unknown error connecting to Evernote: %1");
+ break;
+ }
+ emit errorChanged();
+ return false;
} catch (const TTransportException & e) {
qCWarning(dcConnection) << "Failed to fetch notestore path:" << e.what();
m_errorMessage = QString(gettext("Error connecting to Evernote: Connection failure when downloading server information."));
@@ -321,7 +359,7 @@
return false;
} catch (const TException & e) {
qCWarning(dcConnection) << "Generic Thrift exception when fetching notestore path:" << e.what();
- m_errorMessage = gettext("Unknown error connecting to Evernote");
+ m_errorMessage = gettext("Unknown error connecting to Evernote.");
emit errorChanged();
return false;
}
=== modified file 'src/libqtevernote/evernoteconnection.h'
--- src/libqtevernote/evernoteconnection.h 2015-03-08 21:30:59 +0000
+++ src/libqtevernote/evernoteconnection.h 2015-03-08 21:30:59 +0000
@@ -28,6 +28,7 @@
#include <transport/THttpClient.h>
#include <QObject>
+#include <QTimer>
namespace evernote {
namespace edam {
@@ -141,6 +142,8 @@
evernote::edam::UserStoreClient *m_userstoreClient;
boost::shared_ptr<THttpClient> m_userStoreHttpClient;
+
+ QTimer m_reconnectTimer;
};
#endif // EVERNOTECONNECTION_H
=== modified file 'src/libqtevernote/jobs/evernotejob.cpp'
--- src/libqtevernote/jobs/evernotejob.cpp 2015-03-08 21:30:59 +0000
+++ src/libqtevernote/jobs/evernotejob.cpp 2015-03-08 21:30:59 +0000
@@ -100,6 +100,7 @@
}
} catch (const evernote::edam::EDAMUserException &e) {
QString message;
+ EvernoteConnection::ErrorCode errorCode = EvernoteConnection::ErrorCodeUserException;
switch (e.errorCode) {
case evernote::edam::EDAMErrorCode::UNKNOWN:
message = "Unknown Error: %1";
@@ -118,15 +119,18 @@
break;
case evernote::edam::EDAMErrorCode::LIMIT_REACHED:
message = "Limit reached: %1";
+ errorCode = EvernoteConnection::ErrorCodeLimitExceeded;
break;
case evernote::edam::EDAMErrorCode::QUOTA_REACHED:
message = "Quota reached: %1";
+ errorCode = EvernoteConnection::ErrorCodeQutaExceeded;
break;
case evernote::edam::EDAMErrorCode::INVALID_AUTH:
message = "Invalid auth: %1";
break;
case evernote::edam::EDAMErrorCode::AUTH_EXPIRED:
message = "Auth expired: %1";
+ errorCode = EvernoteConnection::ErrorCodeAuthExpired;
break;
case evernote::edam::EDAMErrorCode::DATA_CONFLICT:
message = "Data conflict: %1";
@@ -161,26 +165,26 @@
}
message = message.arg(QString::fromStdString(e.parameter));
qCWarning(dcJobQueue) << metaObject()->className() << "EDAMUserException:" << message;
- emitJobDone(EvernoteConnection::ErrorCodeUserException, message);
+ emitJobDone(errorCode, message);
} catch (const evernote::edam::EDAMSystemException &e) {
qCWarning(dcJobQueue) << "EDAMSystemException in" << metaObject()->className() << e.what() << e.errorCode << QString::fromStdString(e.message);
QString message;
EvernoteConnection::ErrorCode errorCode;
switch (e.errorCode) {
case evernote::edam::EDAMErrorCode::AUTH_EXPIRED:
- message = gettext("Authentication expired.");
+ message = "Authentication expired.";
errorCode = EvernoteConnection::ErrorCodeAuthExpired;
break;
case evernote::edam::EDAMErrorCode::LIMIT_REACHED:
- message = gettext("Limit exceeded.");
+ message = "Limit exceeded.";
errorCode = EvernoteConnection::ErrorCodeLimitExceeded;
break;
case evernote::edam::EDAMErrorCode::RATE_LIMIT_REACHED:
- message = gettext("Rate limit exceeded.");
+ message = "Rate limit exceeded.";
errorCode = EvernoteConnection::ErrorCodeRateLimitExceeded;
break;
case evernote::edam::EDAMErrorCode::QUOTA_REACHED:
- message = gettext("Quota exceeded.");
+ message = "Quota exceeded.";
errorCode = EvernoteConnection::ErrorCodeQutaExceeded;
break;
default:
=== modified file 'src/libqtevernote/jobs/fetchnotejob.cpp'
--- src/libqtevernote/jobs/fetchnotejob.cpp 2015-02-26 22:47:10 +0000
+++ src/libqtevernote/jobs/fetchnotejob.cpp 2015-03-08 21:30:59 +0000
@@ -53,6 +53,8 @@
void FetchNoteJob::startJob()
{
+ // Just in case we error out, make sure the reply can be idenfied by note guid
+ m_result.guid = m_guid.toStdString();
client()->getNote(m_result, token().toStdString(), m_guid.toStdString(), m_what == LoadContent, m_what == LoadResources, false, false);
}
=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp 2015-03-08 21:30:59 +0000
+++ src/libqtevernote/notesstore.cpp 2015-03-08 21:30:59 +0000
@@ -841,6 +841,11 @@
qCWarning(dcSync) << "FetchNoteJobDone: Item not found on server:" << errorMessage;
emit dataChanged(noteIndex, noteIndex, roles);
return; // silently discarding...
+ case EvernoteConnection::ErrorCodeRateLimitExceeded:
+ qCWarning(dcSync) << "FetchNoteJobDone: Rate limit exceeded:" << errorMessage;
+ m_errorQueue.append(gettext("Cannot download note. Rate limit exceeded"));
+ emit errorChanged();
+ return;
default:
qCWarning(dcSync) << "FetchNoteJobDone: Failed to fetch note content:" << errorMessage << errorCode;
note->setSyncError(true);
@@ -1305,13 +1310,24 @@
int idx = m_notes.indexOf(note);
note->setLoading(false);
- if (errorCode != EvernoteConnection::ErrorCodeNoError) {
- qCWarning(dcSync) << "Error saving note:" << errorMessage;
+ switch (errorCode) {
+ case EvernoteConnection::ErrorCodeNoError:
+ // All is well
+ note->setSyncError(false);
+ break;
+ case EvernoteConnection::ErrorCodeQutaExceeded:
+ qCWarning(dcSync) << "Error saving note. Upload quota reached.";
+ m_errorQueue.append(gettext("Error saving note: Upload quota reached."));
+ emit errorChanged();
+ note->setSyncError(true);
+ emit dataChanged(index(idx), index(idx), QVector<int>() << RoleLoading << RoleSyncError);
+ return;
+ default:
+ qCWarning(dcSync) << "Unhandled error saving note:" << errorCode << "Message:" << errorMessage;
note->setSyncError(true);
emit dataChanged(index(idx), index(idx), QVector<int>() << RoleLoading << RoleSyncError);
return;
}
- note->setSyncError(false);
note->setUpdateSequenceNumber(result.updateSequenceNum);
note->setLastSyncedSequenceNumber(result.updateSequenceNum);
Follow ups