libervia-backend/libervia/backend/plugins/plugin_xep_0373/exceptions.py
Goffi 1745f1e520 plugin XEP-0373: refactor and implement python-gnupg backend:
- split the plugin in several classes, with models, exceptions, and backends separated.
- add a backend for `python-gnupg`, as it can be pip installed without having to use
  `--system-site-packages` in the virtual environment.
- use modern syntax for type hints.

rel 475
2026-02-23 12:56:42 +01:00

63 lines
1.9 KiB
Python

#!/usr/bin/env python3
# Libervia plugin for OpenPGP for XMPP
# Copyright (C) 2025-2026 Jérôme Poisosn (goffi@goffi.org)
# Copyright (C) 2022-2024 Tim Henkes (me@syndace.dev)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class VerificationError(Exception):
"""
Raised by verifying methods of :class:`XEP_0373` on semantical verification errors.
"""
class XMPPInteractionFailed(Exception):
"""
Raised by methods of :class:`XEP_0373` on XMPP interaction failure. The reason this
exception exists is that the exceptions raised by XMPP interactions are not properly
documented for the most part, thus all exceptions are caught and wrapped in instances
of this class.
"""
class InvalidPacket(ValueError):
"""
Raised by methods of :class:`GPGProvider` when an invalid packet is encountered.
"""
class DecryptionFailed(Exception):
"""
Raised by methods of :class:`GPGProvider` on decryption failures.
"""
class VerificationFailed(Exception):
"""
Raised by methods of :class:`GPGProvider` on verification failures.
"""
class UnknownKey(ValueError):
"""
Raised by methods of :class:`GPGProvider` when an unknown key is referenced.
"""
class GPGProviderError(Exception):
"""
Raised by methods of :class:`GPGProvider` on internal errors.
"""