diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2020-04-01 01:33:09 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2020-04-01 01:33:09 +0200 |
commit | da695768b099d91e24c678d7abc70560ff75444a (patch) | |
tree | bc8ad34665f8f9f7da5210e0c1667b54a248ddef /plugins/reorder.py | |
parent | 496752d0db3d54dac7c15220042c9631d587e226 (diff) | |
download | poezio-da695768b099d91e24c678d7abc70560ff75444a.tar.gz poezio-da695768b099d91e24c678d7abc70560ff75444a.tar.bz2 poezio-da695768b099d91e24c678d7abc70560ff75444a.tar.xz poezio-da695768b099d91e24c678d7abc70560ff75444a.zip |
reorder: group exception handling
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'plugins/reorder.py')
-rw-r--r-- | plugins/reorder.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/plugins/reorder.py b/plugins/reorder.py index e61a9925..7be0b350 100644 --- a/plugins/reorder.py +++ b/plugins/reorder.py @@ -167,25 +167,22 @@ class Plugin(BasePlugin): cls, jid = tabs_spec[pos] try: jid = JID(jid) - except InvalidJID: - self.api.information('Reorder: Invalid JID \'%s\'.' % jid, 'Warning') - continue - tab = self.core.tabs.by_name_and_class(str(jid), cls=cls) - if tab and tab in old_tabs: - new_tabs.append(tab) - old_tabs.remove(tab) - else: - self.api.information('Tab %s not found. Creating it' % jid, 'Warning') - # TODO: Add support for MucTab. Requires nickname. - if cls in (tabs.DynamicConversationTab, tabs.StaticConversationTab): - try: + tab = self.core.tabs.by_name_and_class(str(jid), cls=cls) + if tab and tab in old_tabs: + new_tabs.append(tab) + old_tabs.remove(tab) + else: + self.api.information('Tab %s not found. Creating it' % jid, 'Warning') + # TODO: Add support for MucTab. Requires nickname. + if cls in (tabs.DynamicConversationTab, tabs.StaticConversationTab): new_tab = cls(self.core, jid) new_tabs.append(new_tab) - except: - self.api.information('Failed to create tab \'%s\'.' % jid, 'Error') - if create_gaps: - new_tabs.append(tabs.GapTab(self.core)) - last = pos + except: + self.api.information('Failed to create tab \'%s\'.' % jid, 'Error') + if create_gaps: + new_tabs.append(tabs.GapTab(self.core)) + finally: + last = pos for tab in old_tabs: if tab: |