summaryrefslogtreecommitdiffstats
path: root/src/MatrixClient.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-02 15:30:08 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-02 15:30:08 +0300
commit7f69c718143dff456a766c786546a93dd0ee1a75 (patch)
tree3b37cfd9121de5c5c672fb28d17ae895e8fa60b9 /src/MatrixClient.cc
parent23accc50d6f18f063ab4edc4432546a0e6b84b73 (diff)
Handle invalid access token
Diffstat (limited to 'src/MatrixClient.cc')
-rw-r--r--src/MatrixClient.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/MatrixClient.cc b/src/MatrixClient.cc
index 5593dbe6..96f8b941 100644
--- a/src/MatrixClient.cc
+++ b/src/MatrixClient.cc
@@ -309,13 +309,24 @@ MatrixClient::sync() noexcept
reply->deleteLater();
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ auto data = reply->readAll();
if (status == 0 || status >= 400) {
- qDebug() << reply->errorString();
- return;
- }
+ try {
+ mtx::errors::Error res = nlohmann::json::parse(data);
- auto data = reply->readAll();
+ if (res.errcode == mtx::errors::ErrorCode::M_UNKNOWN_TOKEN) {
+ emit invalidToken();
+ return;
+ }
+
+ emit syncError(QString::fromStdString(res.error));
+
+ return;
+ } catch (const nlohmann::json::exception &e) {
+ qWarning() << e.what();
+ }
+ }
try {
mtx::responses::Sync response = nlohmann::json::parse(data);