From 834bb8ebcf8b0b909cdec4164a9b670e456c24fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 16 Jul 2016 09:00:02 +0200 Subject: [PATCH] save traceback in case of error creating ticket (#12607) --- mail2redmine.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mail2redmine.py b/mail2redmine.py index 68c4530..89ac06b 100644 --- a/mail2redmine.py +++ b/mail2redmine.py @@ -7,6 +7,7 @@ import tempfile import uuid import smtplib import subprocess +import traceback import redmine from redmine import Redmine @@ -133,5 +134,9 @@ if __name__ == '__main__': mail_dump.write(mail) try: create_ticket(mail) - except: + except Exception as e: exim = subprocess.Popen(['/usr/sbin/exim', FALLBACK_EMAIL], stdin=file(filename)) + trace = traceback.format_exc() + filename = os.path.join(mail_dumps_dir, '%s.trace' % uuid.uuid4()) + with open(filename, 'w') as mail_dump: + mail_dump.write(trace)