]> git.ipfire.org Git - thirdparty/patchwork.git/commit
parsearchive, mail: use repr() to get a human readable exception
authorDaniel Axtens <dja@axtens.net>
Wed, 18 Sep 2019 06:17:28 +0000 (16:17 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 18 Sep 2019 10:00:22 +0000 (11:00 +0100)
commit47744ffaaf22e095e6d9c3321833c3dcfccce2b1
tree938fd853213ab23e2ee4e2382afa9f97bebab4d9
parent6a716c4267dfbb0122fb20071b70ff560bef3b3a
parsearchive, mail: use repr() to get a human readable exception

Currently if we have particular types of error in mail parsing
in parsearchive or parsemail, we print exc.message, which doesn't
always work:

  Traceback (most recent call last):
    File ".../patchwork/management/commands/parsearchive.py", line 90, in handle
      obj = parse_mail(msg, options['list_id'])
    File ".../patchwork/parser.py", line 961, in parse_mail
      raise ValueError("Missing 'Message-Id' header")
  ValueError: Missing 'Message-Id' header

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "manage.py", line 11, in <module>
      execute_from_command_line(sys.argv)
    File ".../django/core/management/__init__.py", line 381, in execute_from_command_line
      utility.execute()
    File ".../django/core/management/__init__.py", line 375, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File ".../django/core/management/base.py", line 323, in run_from_argv
      self.execute(*args, **cmd_options)
    File ".../django/core/management/base.py", line 364, in execute
      output = self.handle(*args, **options)
    File ".../patchwork/management/commands/parsearchive.py", line 100, in handle
      logger.warning('Invalid mail: %s', exc.message)
  AttributeError: 'ValueError' object has no attribute 'message'

repr(exc) will work. Use it.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
(cherry picked from commit 319b6f9d750c220d47c1044246d4e97fd500c6d4)
patchwork/management/commands/parsearchive.py
patchwork/management/commands/parsemail.py