From 93002c49100d0c71dc567276e8755d2373c84102 Mon Sep 17 00:00:00 2001 From: "Piotr F. Mieszkowski" Date: Fri, 13 Sep 2024 12:22:17 +0200 Subject: [PATCH] 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. --- lacre/core.py | 4 ++-- lacre/daemon.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lacre/core.py b/lacre/core.py index 1239eb3..3c6a121 100644 --- a/lacre/core.py +++ b/lacre/core.py @@ -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: diff --git a/lacre/daemon.py b/lacre/daemon.py index 137b890..2d4ffe3 100644 --- a/lacre/daemon.py +++ b/lacre/daemon.py @@ -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: