Browse Source

Enable warnings as errors; show exception messages.

master
Julio Biason 15 years ago
parent
commit
755065359c
  1. 26
      mitterlib/ui/ui_pygtk.py

26
mitterlib/ui/ui_pygtk.py

@ -26,6 +26,7 @@ import logging
import urllib2 import urllib2
import gettext import gettext
import datetime import datetime
import warnings
from mitterlib.ui.helpers.image_helpers import find_image from mitterlib.ui.helpers.image_helpers import find_image
from mitterlib.ui.helpers.gtk_threading import ThreadManager from mitterlib.ui.helpers.gtk_threading import ThreadManager
@ -801,11 +802,11 @@ class Interface(object):
"""Function called if the retrival of current messages returns an """Function called if the retrival of current messages returns an
exception.""" exception."""
_log.debug(str(exception)) _log.debug(str(exception))
message = _('%s\nAuto-refresh is now disabled. Use the "refresh" ' \
'option to re-enable it.') % (str(exception))
error_win = gtk.MessageDialog(parent=self._main_window, error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR, type=gtk.MESSAGE_ERROR,
message_format=_('Error retrieving current messages. ' \ message_format=_message,
'Auto-refresh disabled. Use the "Refresh" option ' \
'to re-enable it.'),
buttons=gtk.BUTTONS_OK) buttons=gtk.BUTTONS_OK)
error_win.run() error_win.run()
error_win.hide() error_win.hide()
@ -902,10 +903,10 @@ class Interface(object):
"""Called when there is an exception updating the status.""" """Called when there is an exception updating the status."""
_log.debug('Update error') _log.debug('Update error')
_log.debug(str(exception)) _log.debug(str(exception))
message = _('%s\nPlease, try again.') % (message)
error_win = gtk.MessageDialog(parent=self._main_window, error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR, type=gtk.MESSAGE_ERROR,
message_format=_('Error updating your status. Please ' \ message_format=message,
'try again.'),
buttons=gtk.BUTTONS_OK) buttons=gtk.BUTTONS_OK)
error_win.run() error_win.run()
error_win.hide() error_win.hide()
@ -928,6 +929,12 @@ class Interface(object):
"""Called when the message cannot be deleted.""" """Called when the message cannot be deleted."""
_log.debug('Delete error') _log.debug('Delete error')
_log.debug(str(exception)) _log.debug(str(exception))
error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR,
message_format=str(exception),
buttons=gtk.BUTTONS_OK)
error_win.run()
error_win.hide()
return return
### Results for the repost message call ### Results for the repost message call
@ -944,8 +951,7 @@ class Interface(object):
error_win = gtk.MessageDialog(parent=self._main_window, error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR, type=gtk.MESSAGE_ERROR,
message_format=_('Error reposting message. Please ' \ message_format=str(exception),
'try again.'),
buttons=gtk.BUTTONS_OK) buttons=gtk.BUTTONS_OK)
error_win.run() error_win.run()
error_win.hide() error_win.hide()
@ -969,8 +975,7 @@ class Interface(object):
error_win = gtk.MessageDialog(parent=self._main_window, error_win = gtk.MessageDialog(parent=self._main_window,
type=gtk.MESSAGE_ERROR, type=gtk.MESSAGE_ERROR,
message_format=_('Error changing favorite status of the ' \ message_format=str(exception),
'message. Please, try again.'),
buttons=gtk.BUTTONS_OK) buttons=gtk.BUTTONS_OK)
error_win.run() error_win.run()
error_win.hide() error_win.hide()
@ -1018,6 +1023,9 @@ class Interface(object):
"""Call function; displays the interface. This method should """Call function; displays the interface. This method should
appear on every interface.""" appear on every interface."""
# turn warnings into exception (so we can catch them)
warnings.simplefilter('error')
if self._options[self.NAMESPACE]['statusicon']: if self._options[self.NAMESPACE]['statusicon']:
self._statusicon = gtk.StatusIcon() self._statusicon = gtk.StatusIcon()
self._statusicon.set_from_pixbuf(self._images['icon']) self._statusicon.set_from_pixbuf(self._images['icon'])

Loading…
Cancel
Save