plugin XEP-0373: Fix local exceptions shadowing core.exceptions
This commit is contained in:
parent
7107d64a5b
commit
09848498cd
1 changed files with 33 additions and 18 deletions
|
|
@ -46,7 +46,7 @@ from tx_xmpp import muc, pubsub
|
|||
from tx_xmpp.disco import DiscoFeature, DiscoInfo
|
||||
import xmlschema
|
||||
|
||||
from .exceptions import VerificationError, XMPPInteractionFailed
|
||||
from . import exceptions as xep_0373_exceptions
|
||||
from .models import GPGProviderBase, GPGPublicKeyBase, GPGSecretKeyBase
|
||||
|
||||
try:
|
||||
|
|
@ -737,7 +737,8 @@ class XEP_0373:
|
|||
extension elements carried by this ``<openpgp/>`` element, and the timestamp
|
||||
contained in the content element.
|
||||
@raise exceptions.ParsingError: on syntactical verification errors.
|
||||
@raise VerificationError: on semantical verification errors accoding to XEP-0373.
|
||||
@raise xep_0373_exceptions.VerificationError: on semantical verification errors
|
||||
accoding to XEP-0373.
|
||||
@raise DecryptionFailed: on decryption failure.
|
||||
@raise VerificationFailed: if the data could not be verified.
|
||||
|
||||
|
|
@ -808,7 +809,7 @@ class XEP_0373:
|
|||
client.jid.userhostJID() not in {jid.userhostJID() for jid in recipient_jids}
|
||||
and element_name != "crypt"
|
||||
):
|
||||
raise VerificationError(
|
||||
raise xep_0373_exceptions.VerificationError(
|
||||
f"Recipient list in <{element_name}/> element does not list our (bare)"
|
||||
" JID."
|
||||
)
|
||||
|
|
@ -828,7 +829,8 @@ class XEP_0373:
|
|||
|
||||
@param client: The client.
|
||||
@param public_key: The public key to publish.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
"""
|
||||
|
||||
gpg_provider = get_gpg_provider(self.host, client)
|
||||
|
|
@ -859,7 +861,9 @@ class XEP_0373:
|
|||
},
|
||||
)
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed("Publishing the public key failed.") from e
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Publishing the public key failed."
|
||||
) from e
|
||||
|
||||
async def import_all_public_keys(
|
||||
self, client: SatXMPPClient, entity_jid: jid.JID
|
||||
|
|
@ -930,7 +934,8 @@ class XEP_0373:
|
|||
@raise exceptions.ParsingError: on XML-level parsing errors.
|
||||
@raise InvalidPacket: if the packet is either syntactically or semantically deemed
|
||||
invalid.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
"""
|
||||
|
||||
gpg_provider = get_gpg_provider(self.host, client)
|
||||
|
|
@ -947,7 +952,9 @@ class XEP_0373:
|
|||
f" {jid.userhost()}."
|
||||
) from e
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed("Fetching the public keys list failed.") from e
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Fetching the public keys list failed."
|
||||
) from e
|
||||
|
||||
try:
|
||||
item_elt = cast(domish.Element, items[0])
|
||||
|
|
@ -988,7 +995,8 @@ class XEP_0373:
|
|||
|
||||
@param client: The client.
|
||||
@param public_keys_list: The public keys list.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
|
||||
@warning: All public keys referenced in the public keys list MUST be published
|
||||
beforehand.
|
||||
|
|
@ -1024,7 +1032,9 @@ class XEP_0373:
|
|||
},
|
||||
)
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed("Publishing the public keys list failed.") from e
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Publishing the public keys list failed."
|
||||
) from e
|
||||
|
||||
async def download_public_keys_list(
|
||||
self, client: SatXMPPClient, jid: jid.JID
|
||||
|
|
@ -1036,7 +1046,8 @@ class XEP_0373:
|
|||
@return: The public keys list or ``None`` if the JID hasn't published a public
|
||||
keys list. An empty list means the JID has published an empty list.
|
||||
@raise exceptions.ParsingError: on XML-level parsing errors.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
"""
|
||||
|
||||
node = "urn:xmpp:openpgp:0:public-keys"
|
||||
|
|
@ -1048,7 +1059,7 @@ class XEP_0373:
|
|||
except exceptions.NotFound:
|
||||
return None
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed() from e
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed() from e
|
||||
|
||||
try:
|
||||
item_elt = cast(domish.Element, items[0])
|
||||
|
|
@ -1095,7 +1106,8 @@ class XEP_0373:
|
|||
fetched. The result of that fetch is returned here.
|
||||
@raise exceptions.FeatureNotFound: if the server lacks support for the required
|
||||
protocols or protocol extensions.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
"""
|
||||
|
||||
try:
|
||||
|
|
@ -1104,7 +1116,7 @@ class XEP_0373:
|
|||
await self.host.memory.disco.get_infos(client, client.jid.userhostJID()),
|
||||
)
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed(
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Error performing service discovery on the own bare JID."
|
||||
) from e
|
||||
|
||||
|
|
@ -1146,11 +1158,11 @@ class XEP_0373:
|
|||
},
|
||||
)
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed(
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Error creating the secret key synchronization node."
|
||||
) from e
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed(
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Error fetching the secret key synchronization node."
|
||||
) from e
|
||||
|
||||
|
|
@ -1169,7 +1181,8 @@ class XEP_0373:
|
|||
@return: The backup code needed to decrypt the exported secret keys.
|
||||
@raise exceptions.FeatureNotFound: if the server lacks support for the required
|
||||
protocols or protocol extensions.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP
|
||||
failed.
|
||||
"""
|
||||
|
||||
gpg_provider = get_gpg_provider(self.host, client)
|
||||
|
|
@ -1194,7 +1207,9 @@ class XEP_0373:
|
|||
client, client.jid.userhostJID(), node, secretkey_elt
|
||||
)
|
||||
except Exception as e:
|
||||
raise XMPPInteractionFailed("Publishing the secret keys failed.") from e
|
||||
raise xep_0373_exceptions.XMPPInteractionFailed(
|
||||
"Publishing the secret keys failed."
|
||||
) from e
|
||||
|
||||
return backup_code
|
||||
|
||||
|
|
@ -1211,7 +1226,7 @@ class XEP_0373:
|
|||
@raise exceptions.FeatureNotFound: if the server lacks support for the required
|
||||
protocols or protocol extensions.
|
||||
@raise exceptions.ParsingError: on XML-level parsing errors.
|
||||
@raise XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
@raise xep_0373_exceptions.XMPPInteractionFailed: if any interaction via XMPP failed.
|
||||
"""
|
||||
|
||||
item_elt = await self.__prepare_secret_key_synchronization(client)
|
||||
|
|
|
|||
Loading…
Reference in a new issue