From 37c9f204c7af3374f7893bfff8bdc03e26eabba6 Mon Sep 17 00:00:00 2001 From: Shiz Date: Sat, 22 Feb 2014 11:59:56 +0100 Subject: [PATCH] Add server-side error message handler. --- pydle/features/rfc1459/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pydle/features/rfc1459/client.py b/pydle/features/rfc1459/client.py index 53b02ea..17821b8 100644 --- a/pydle/features/rfc1459/client.py +++ b/pydle/features/rfc1459/client.py @@ -5,11 +5,15 @@ import itertools import copy from pydle.async import Future -from pydle.client import BasicClient, NotInChannel, AlreadyInChannel +from pydle.client import BasicClient, NotInChannel, AlreadyInChannel, Error from . import parsing from . import protocol +class ServerSideError(Error): + pass + + class RFC1459Support(BasicClient): """ Basic RFC1459 client. """ DEFAULT_QUIT_MESSAGE = 'Quitting' @@ -402,6 +406,11 @@ class RFC1459Support(BasicClient): ## Callback handlers. + def on_raw_error(self, message): + """ Server encountered an error and will now close the connection. """ + error = ServerSideError(' '.join(message.params)) + self.on_data_error(error) + def on_raw_invite(self, message): """ INVITE command. """ nick, metadata = self._parse_user(message.source)