Fix unprintable exception issue

This commit is contained in:
Piotr F. Mieszkowski 2023-12-09 20:57:09 +01:00
parent 75c48282b0
commit fe2c0cbf76
2 changed files with 10 additions and 21 deletions

View File

@ -45,26 +45,15 @@ RX_CONFIRM = re.compile(br'key "([^"]+)" imported')
class EncryptionException(Exception):
"""Represents a failure to encrypt a payload."""
"""Represents a failure to encrypt a payload.
def __str__(self):
"""Return human-readable string representation."""
recipient, issue, cause, key = self.args
parts = []
if recipient:
parts.append('To: ' + recipient)
if issue:
parts.append('Issue: ' + issue)
if key:
parts.append('Key: ' + key.decode())
if cause:
parts.append('Cause: ' + cause)
return '; '.join(parts)
Arguments passed to exception constructor:
- issue: human-readable explanation of the issue;
- recipient: owner of the key;
- cause: any additional information, if present;
- key: fingerprint of the key.
"""
pass
def _build_command(key_home, *args, **kwargs):

View File

@ -59,8 +59,8 @@ class MailEncryptionProxy:
if not isinstance(operation, KeepIntact):
self._send_unencrypted(operation, message, envelope, send)
else:
LOG.error('Cannot perform: %s', operation)
raise e
LOG.exception('Cannot perform: %s', operation)
raise
except:
LOG.exception('Unexpected exception caught, bouncing message')