Skip to content

Commit

Permalink
Add exc_info to logger.error
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrew82 committed Mar 19, 2024
1 parent fa7f114 commit 11bed6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nornir_nautobot/plugins/tasks/dispatcher/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,27 @@ def generate_config(
except NornirSubTaskError as exc:
if isinstance(exc.result.exception, jinja2.exceptions.UndefinedError): # pylint: disable=no-else-raise
error_msg = f"`E1010:` There was a jinja2.exceptions.UndefinedError error: ``{str(exc.result.exception)}``"
logger.error(error_msg, extra={"object": obj})
logger.error(error_msg, extra={"object": obj}, exc_info=True)
# raise NornirNautobotException(error_msg)
raise exc.result.exception

elif isinstance(exc.result.exception, jinja2.TemplateSyntaxError):
error_msg = (
f"`E1011:` There was a jinja2.TemplateSyntaxError error: ``{str(exc.result.exception)}``",
)
logger.error(error_msg, extra={"object": obj})
logger.error(error_msg, extra={"object": obj}, exc_info=True)
# raise NornirNautobotException(error_msg)
raise exc.result.exception

elif isinstance(exc.result.exception, jinja2.TemplateNotFound):
error_msg = f"`E1012:` There was an issue finding the template and a jinja2.TemplateNotFound error was raised: ``{str(exc.result.exception)}``"
logger.error(error_msg, extra={"object": obj})
logger.error(error_msg, extra={"object": obj}, exc_info=True)
# raise NornirNautobotException(error_msg)
raise exc.result.exception

elif isinstance(exc.result.exception, jinja2.TemplateError):
error_msg = f"`E1013:` There was an issue general Jinja error: ``{str(exc.result.exception)}``"
logger.error(error_msg, extra={"object": obj})
logger.error(error_msg, extra={"object": obj}, exc_info=True)
# raise NornirNautobotException(error_msg)
raise exc.result.exception

Expand Down

0 comments on commit 11bed6d

Please sign in to comment.