Fix exception logging

When an exception happens while executing the method `_load_param_file`,
the exception logging `LOG.exception(exc_info=exc)` will generate an
error.

A small snippet to reproduce the issue is the following code:

  from sphinx.util import logging

  LOG = logging.getLogger(__name__)

  try:
      raise Exception("teste")
  except Exception as exc:
      LOG.exception(exc_info=exc)

Which will generate the error:

  Exception: teste

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/home/rafael/git/os-api-ref/os_api_ref/test-logging.py", line 8, in <module>
      LOG.exception(exc_info=exc)
  TypeError: exception() missing 1 required positional argument: 'msg'

  Process finished with exit code 1

With this fix, the exception logging error is solved, and users get a
meaningful message.

Change-Id: Ib3c3e93c283d86b9708c74e60c2ac5762dc2c222
This commit is contained in:
Rafael Weingärtner 2021-07-02 11:51:39 -03:00 committed by Stephen Finucane
parent 8aa8e71799
commit 3d4f056ca3
1 changed files with 2 additions and 1 deletions

View File

@ -229,7 +229,8 @@ class RestParametersDirective(Table):
location=(self.env.docname, None))
return
except yaml.YAMLError as exc:
LOG.exception(exc_info=exc)
LOG.exception(exc_info=exc,
msg="Error while parsing file [%s]." % fpath)
raise
if lookup: