diff --git a/changelog.md b/changelog.md index a638d3d..2e04110 100644 --- a/changelog.md +++ b/changelog.md @@ -36,6 +36,7 @@ * Authentication errors should be handled gracefully by the application: * When there is a password change, Socializer must be reauthorized again. An error message will indicate this if the user forgot to do that. After the error, the app will be restarted, prompting the user to introduce the new data for authorizing the application. * If the user introduced incorrect or invalid data, Socializer will display an error and prompt the user again for valid information. + * If there is a connection problem when opening Socializer, it will display an error and inform the user about the issue. ## Changes in version 0.18 (21.01.2019) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 9a3b07b..6fe965d 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -286,6 +286,7 @@ class Controller(object): pub.subscribe(self.update_status_bar, "update-status-bar") pub.subscribe(self.chat_from_id, "new-chat") pub.subscribe(self.authorisation_failed, "authorisation-failed") + pub.subscribe(self.connection_error, "connection_error") pub.subscribe(self.user_profile, "user-profile") pub.subscribe(self.user_online, "user-online") pub.subscribe(self.user_offline, "user-offline") @@ -391,6 +392,15 @@ class Controller(object): commonMessages.bad_authorisation() restart.restart_program() + def connection_error(self, *args, **kwargs): + commonMessages.connection_error() + self.disconnect_events() + volume = player.player.volume + config.app["sound"]["volume"] = volume + config.app.write() + self.window.Destroy() + wx.GetApp().ExitMainLoop() + def user_profile(self, person): """ display someone's profile. For now, only users are supported.""" p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor()) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index cd83048..070b01a 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -8,6 +8,7 @@ import languageHandler import paths import config import sound +from requests.exceptions import ProxyError, ConnectionError from .config_utils import Configuration, ConfigurationResetException from . import vkSessionHandler from pubsub import pub @@ -110,6 +111,8 @@ class vkSession(object): # log.exception("The session configuration has failed.") def login(self): + """ Logging in VK.com. This is basically the first method interacting with VK. """ + # If user is already logged in, we should skip this method. if self.logged == True: return try: @@ -130,10 +133,12 @@ class vkSession(object): self.settings["vk"]["device_id"] = "" self.settings.write() pub.sendMessage("authorisation-failed") - else: # print out error so we we will handle it. + else: # print out error so we we will handle it in future versions. log.exception("Fatal error when authenticating the application.") log.exception(error.code) log.exception(error.message) + except (ProxyError, ConnectionError): + pub.sendMessage("connection_error") def post_wall_status(self, message, *args, **kwargs): """ Sends a post to an user, group or community wall."""