Skip to content
Snippets Groups Projects
Commit 96d89030 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Added proper connection error handling.

parent 692d3737
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,12 @@ class ClientConnection(object, AsyncBase, asyncore.dispatcher):
if 'connect' in self.event_list:
self.event_list['connect'](self)
def handle_error(self):
if hasattr(self, 'main'):
self.main.execute('disconnect')
self.main.display_info('Error raised due to a broken or refused'\
+ ' connection')
def handle_close(self):
self.close()
......
......@@ -16,15 +16,15 @@ class BaseBar(object):
self.color_pair = curses.color_pair(0)
self._prefix = ''
def prefix(self, value=''):
if not value:
def prefix(self, value=None):
if value == None: # Note: an empty string can also be set.
return self._prefix
self._prefix = value
self.display(self._msg)
def display(self, msg):
self._msg = msg
if self.prefix:
if self.prefix():
msg = self.prefix() + ' ' + msg
# Curses will raise a 'curses.error' when the last possible character is
# written. This exception should therefore always be catched. The raised
......
......@@ -158,7 +158,9 @@ class CLI:
self.connection = None
self.display_info('Offline. Type "/connect HOST" to connect' \
+ ' to another chat server.')
self.info_bar.prefix('')
self.debug_window.clear()
self.refresh()
def help(main):
if main.chat_window.displayed_help:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment