Log encryption failure tracebacks

When we fail to encrypt a message, we log a message with a complete traceback.
The goal is to ensure that when diagnosing it later, we have complete
information.
This commit is contained in:
Piotr F. Mieszkowski 2024-09-13 12:22:17 +02:00
parent c1c4bd1573
commit 93002c4910
Signed by: pfm
GPG key ID: BDE5BC1FA5DC53D5
2 changed files with 3 additions and 3 deletions

View file

@ -133,8 +133,8 @@ def _gpg_encrypt_to_bytes(message: EmailMessage, keys, recipients, encrypt_f, lm
msg_copy = _gpg_encrypt_copy(message, keys, recipients, encrypt_f, lmessage)
try:
return msg_copy.as_bytes(policy=SMTPUTF8)
except IndexError:
raise MailSerialisationException()
except IndexError as ie:
raise MailSerialisationException(ie)
def _gpg_encrypt_to_str(message: EmailMessage, keys, recipients, encrypt_f) -> str:

View file

@ -54,7 +54,7 @@ class MailEncryptionProxy:
# If the message can't be encrypted or serialised to a
# stream of bytes, deliver original payload in
# cleartext.
LOG.error('Unable to encrypt message, delivering in cleartext: %s', e)
LOG.exception('Unable to encrypt message, delivering in cleartext: %s')
self._send_unencrypted(operation, envelope, send)
except xport.TransientFailure: