View profile: Shows an error if user does not exist. Fixes #114

This commit is contained in:
Manuel Cortez 2017-02-01 03:23:29 -06:00
parent 4d82ecc8f2
commit a86a6f52d6

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import wx
import webbrowser import webbrowser
import widgetUtils import widgetUtils
import output import output
@ -12,14 +13,19 @@ class profileController(object):
self.session = session self.session = session
self.user = user self.user = user
if user == None: if user == None:
self.dialog = update_profile.updateProfileDialog()
self.get_data(screen_name=self.session.db["user_name"]) self.get_data(screen_name=self.session.db["user_name"])
self.dialog = update_profile.updateProfileDialog()
self.fill_profile_fields() self.fill_profile_fields()
self.uploaded = False self.uploaded = False
widgetUtils.connect_event(self.dialog.upload_image, widgetUtils.BUTTON_PRESSED, self.upload_image) widgetUtils.connect_event(self.dialog.upload_image, widgetUtils.BUTTON_PRESSED, self.upload_image)
else: else:
self.dialog = show_user.showUserProfile() try:
self.get_data(screen_name=self.user) self.get_data(screen_name=self.user)
except TwythonError as err:
if err.error_code == 404:
wx.MessageDialog(None, _(u"That user does not exist"), _(u"Error"), wx.ICON_ERROR).ShowModal()
return
self.dialog = show_user.showUserProfile()
string = self.get_user_info() string = self.get_user_info()
self.dialog.set("text", string) self.dialog.set("text", string)
self.dialog.set_title(_(u"Information for %s") % (self.data["screen_name"])) self.dialog.set_title(_(u"Information for %s") % (self.data["screen_name"]))