Cleanup error reporting
This commit is contained in:
@@ -227,21 +227,21 @@ void Controller::invokeLogin()
|
|||||||
});
|
});
|
||||||
connect(connection, &NeoChatConnection::loginError, this, [this, connection](const QString &error, const QString &) {
|
connect(connection, &NeoChatConnection::loginError, this, [this, connection](const QString &error, const QString &) {
|
||||||
if (error == "Unrecognised access token"_ls) {
|
if (error == "Unrecognised access token"_ls) {
|
||||||
Q_EMIT errorOccured(i18n("Login Failed: Access Token invalid or revoked"));
|
Q_EMIT errorOccured(i18n("Login Failed: Access Token invalid or revoked"), {});
|
||||||
connection->logout(false);
|
connection->logout(false);
|
||||||
} else if (error == "Connection closed"_ls) {
|
} else if (error == "Connection closed"_ls) {
|
||||||
Q_EMIT errorOccured(i18n("Login Failed: %1", error));
|
Q_EMIT errorOccured(i18n("Login Failed: %1", error), {});
|
||||||
// Failed due to network connection issue. This might happen when the homeserver is
|
// Failed due to network connection issue. This might happen when the homeserver is
|
||||||
// temporary down, or the user trying to re-launch NeoChat in a network that cannot
|
// temporary down, or the user trying to re-launch NeoChat in a network that cannot
|
||||||
// connect to the homeserver. In this case, we don't want to do logout().
|
// connect to the homeserver. In this case, we don't want to do logout().
|
||||||
} else {
|
} else {
|
||||||
Q_EMIT errorOccured(i18n("Login Failed: %1", error));
|
Q_EMIT errorOccured(i18n("Login Failed: %1", error), {});
|
||||||
connection->logout(true);
|
connection->logout(true);
|
||||||
}
|
}
|
||||||
Q_EMIT initiated();
|
Q_EMIT initiated();
|
||||||
});
|
});
|
||||||
connect(connection, &NeoChatConnection::networkError, this, [this](const QString &error, const QString &, int, int) {
|
connect(connection, &NeoChatConnection::networkError, this, [this](const QString &error, const QString &, int, int) {
|
||||||
Q_EMIT errorOccured(i18n("Network Error: %1", error));
|
Q_EMIT errorOccured(i18n("Network Error: %1", error), {});
|
||||||
});
|
});
|
||||||
connection->assumeIdentity(account.userId(), accessToken);
|
connection->assumeIdentity(account.userId(), accessToken);
|
||||||
});
|
});
|
||||||
@@ -266,17 +266,17 @@ QKeychain::ReadPasswordJob *Controller::loadAccessTokenFromKeyChain(const Accoun
|
|||||||
|
|
||||||
switch (job->error()) {
|
switch (job->error()) {
|
||||||
case QKeychain::EntryNotFound:
|
case QKeychain::EntryNotFound:
|
||||||
Q_EMIT globalErrorOccured(i18n("Access token wasn't found"), i18n("Maybe it was deleted?"));
|
Q_EMIT errorOccured(i18n("Access token wasn't found"), i18n("Maybe it was deleted?"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::AccessDeniedByUser:
|
case QKeychain::AccessDeniedByUser:
|
||||||
case QKeychain::AccessDenied:
|
case QKeychain::AccessDenied:
|
||||||
Q_EMIT globalErrorOccured(i18n("Access to keychain was denied."), i18n("Please allow NeoChat to read the access token"));
|
Q_EMIT errorOccured(i18n("Access to keychain was denied."), i18n("Please allow NeoChat to read the access token"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::NoBackendAvailable:
|
case QKeychain::NoBackendAvailable:
|
||||||
Q_EMIT globalErrorOccured(i18n("No keychain available."), i18n("Please install a keychain, e.g. KWallet or GNOME keyring on Linux"));
|
Q_EMIT errorOccured(i18n("No keychain available."), i18n("Please install a keychain, e.g. KWallet or GNOME keyring on Linux"));
|
||||||
break;
|
break;
|
||||||
case QKeychain::OtherError:
|
case QKeychain::OtherError:
|
||||||
Q_EMIT globalErrorOccured(i18n("Unable to read access token"), job->errorString());
|
Q_EMIT errorOccured(i18n("Unable to read access token"), job->errorString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -140,11 +140,7 @@ private Q_SLOTS:
|
|||||||
void setQuitOnLastWindowClosed();
|
void setQuitOnLastWindowClosed();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/// Error occurred because of user inputs
|
void errorOccured(const QString &error, const QString &detail);
|
||||||
void errorOccured(const QString &error);
|
|
||||||
|
|
||||||
/// Error occurred because of server or bug in NeoChat
|
|
||||||
void globalErrorOccured(QString error, QString detail);
|
|
||||||
void syncDone();
|
void syncDone();
|
||||||
void connectionAdded(NeoChatConnection *connection);
|
void connectionAdded(NeoChatConnection *connection);
|
||||||
void connectionDropped(NeoChatConnection *connection);
|
void connectionDropped(NeoChatConnection *connection);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void LoginHelper::init()
|
|||||||
m_connection = nullptr;
|
m_connection = nullptr;
|
||||||
});
|
});
|
||||||
connect(m_connection, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
connect(m_connection, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
||||||
Q_EMIT Controller::instance().globalErrorOccured(i18n("Network Error"), std::move(error));
|
Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error));
|
||||||
m_isLoggingIn = false;
|
m_isLoggingIn = false;
|
||||||
Q_EMIT isLoggingInChanged();
|
Q_EMIT isLoggingInChanged();
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ void LoginHelper::init()
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(m_connection, &Connection::resolveError, this, [](QString error) {
|
connect(m_connection, &Connection::resolveError, this, [](QString error) {
|
||||||
Q_EMIT Controller::instance().globalErrorOccured(i18n("Network Error"), std::move(error));
|
Q_EMIT Controller::instance().errorOccured(i18n("Network Error"), std::move(error));
|
||||||
});
|
});
|
||||||
|
|
||||||
connectSingleShot(m_connection, &Connection::syncDone, this, [this]() {
|
connectSingleShot(m_connection, &Connection::syncDone, this, [this]() {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ void NeoChatConnection::createRoom(const QString &name, const QString &topic, co
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(job, &CreateRoomJob::failure, this, [job] {
|
connect(job, &CreateRoomJob::failure, this, [job] {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()));
|
Q_EMIT Controller::instance().errorOccured(i18n("Room creation failed: %1", job->errorString()), {});
|
||||||
});
|
});
|
||||||
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
||||||
@@ -226,7 +226,7 @@ void NeoChatConnection::createSpace(const QString &name, const QString &topic, c
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(job, &CreateRoomJob::failure, this, [job] {
|
connect(job, &CreateRoomJob::failure, this, [job] {
|
||||||
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()));
|
Q_EMIT Controller::instance().errorOccured(i18n("Space creation failed: %1", job->errorString()), {});
|
||||||
});
|
});
|
||||||
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
connectSingleShot(this, &Connection::newRoom, this, [](Room *room) {
|
||||||
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
RoomManager::instance().enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ Kirigami.ApplicationWindow {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Controller
|
target: Controller
|
||||||
|
|
||||||
function onGlobalErrorOccured(error, detail) {
|
function onErrorOccured(error, detail) {
|
||||||
showPassiveNotification(i18n("%1: %2", error, detail));
|
showPassiveNotification(detail.length > 0 ? i18n("%1: %2", error, detail) : error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserConsentRequired(url) {
|
function onUserConsentRequired(url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user