comparison src/plugins/plugin_xep_0045.py @ 1742:244a605623d6

complete the Exception's list when catching JID error: - Twisted JID constructor raises not only jid.InvalidFormat but also RuntimeError and AttributeError
author souliane <souliane@mailoo.org>
date Tue, 15 Dec 2015 13:30:47 +0100
parents 0502a1fbe8b5
children d17772b0fe22
comparison
equal deleted inserted replaced
1741:cc31dd72526d 1742:244a605623d6
560 try: 560 try:
561 jid_s = options[0] 561 jid_s = options[0]
562 entity_jid = jid.JID(jid_s).userhostJID() 562 entity_jid = jid.JID(jid_s).userhostJID()
563 assert(entity_jid.user) 563 assert(entity_jid.user)
564 assert(entity_jid.host) 564 assert(entity_jid.host)
565 except (IndexError, jid.InvalidFormat, AssertionError): 565 except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError, AssertionError):
566 feedback = _(u"You must provide a valid JID to ban, like in '/ban contact@example.net'") 566 feedback = _(u"You must provide a valid JID to ban, like in '/ban contact@example.net'")
567 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) 567 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile)
568 return False 568 return False
569 569
570 d = self.ban(entity_jid, mess_data["to"], {} if len(options) == 1 else {'reason': options[1]}, profile) 570 d = self.ban(entity_jid, mess_data["to"], {} if len(options) == 1 else {'reason': options[1]}, profile)
592 try: 592 try:
593 jid_s = options[0] 593 jid_s = options[0]
594 entity_jid = jid.JID(jid_s).userhostJID() 594 entity_jid = jid.JID(jid_s).userhostJID()
595 assert(entity_jid.user) 595 assert(entity_jid.user)
596 assert(entity_jid.host) 596 assert(entity_jid.host)
597 except (IndexError, jid.InvalidFormat, AssertionError): 597 except (RuntimeError, jid.InvalidFormat, AttributeError, IndexError, AssertionError):
598 feedback = _(u"You must provide a valid JID to affiliate, like in '/affiliate contact@example.net member'") 598 feedback = _(u"You must provide a valid JID to affiliate, like in '/affiliate contact@example.net member'")
599 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) 599 self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile)
600 return False 600 return False
601 601
602 affiliation = options[1] if len(options) > 1 else 'none' 602 affiliation = options[1] if len(options) > 1 else 'none'