From 08f48b0c8be7535754ba9494d13276f69485bd44 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 12 Dec 2020 22:51:34 +0100 Subject: Move get_error_message to common --- poezio/core/core.py | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'poezio/core/core.py') diff --git a/poezio/core/core.py b/poezio/core/core.py index 2151600f..c79750de 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -45,6 +45,7 @@ from poezio import timed_events from poezio import windows from poezio.bookmarks import BookmarkList +from poezio.common import get_error_message from poezio.config import config, firstrun from poezio.contact import Contact, Resource from poezio.daemon import Executor @@ -66,8 +67,6 @@ from poezio.core.handlers import HandlerCore from poezio.core.structs import ( Command, Status, - DEPRECATED_ERRORS, - ERROR_AND_STATUS_CODES, POSSIBLE_SHOW, ) @@ -989,42 +988,6 @@ class Core: for jid in jids: self.invite(jid, room) - def get_error_message(self, stanza, deprecated: bool = False): - """ - Takes a stanza of the form - and return a well formed string containing error information - """ - sender = stanza['from'] - msg = stanza['error']['type'] - condition = stanza['error']['condition'] - code = stanza['error']['code'] - body = stanza['error']['text'] - if not body: - if deprecated: - if code in DEPRECATED_ERRORS: - body = DEPRECATED_ERRORS[code] - else: - body = condition or 'Unknown error' - else: - if code in ERROR_AND_STATUS_CODES: - body = ERROR_AND_STATUS_CODES[code] - else: - body = condition or 'Unknown error' - if code: - message = '%(from)s: %(code)s - %(msg)s: %(body)s' % { - 'from': sender, - 'msg': msg, - 'body': body, - 'code': code - } - else: - message = '%(from)s: %(msg)s: %(body)s' % { - 'from': sender, - 'msg': msg, - 'body': body - } - return message - ####################### Tab logic-related things ############################## ### Tab getters ### @@ -2125,7 +2088,7 @@ class Core: tab = self.tabs.by_name_and_class(room_name, tabs.MucTab) if not tab: return - error_message = self.get_error_message(error) + error_message = get_error_message(error) tab.add_message( Message( error_message, -- cgit v1.2.3