From 4886760d8773607f9d105e66e2c32ff145ac0edb Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:24:43 -0500 Subject: [PATCH] fix: Use tb_listi --- nornir_nautobot/plugins/tasks/dispatcher/default.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nornir_nautobot/plugins/tasks/dispatcher/default.py b/nornir_nautobot/plugins/tasks/dispatcher/default.py index b749cf2..7296121 100644 --- a/nornir_nautobot/plugins/tasks/dispatcher/default.py +++ b/nornir_nautobot/plugins/tasks/dispatcher/default.py @@ -173,24 +173,24 @@ def generate_config( )[0].result 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)}`` and ``{str(exc.result.exception.__traceback__)}``" + error_msg = f"`E1010:` There was a jinja2.exceptions.UndefinedError error: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__.tb_lasti)}``" logger.error(error_msg, extra={"object": obj, "exc_info": True}) raise NornirNautobotException(error_msg) elif isinstance(exc.result.exception, jinja2.TemplateSyntaxError): error_msg = ( - f"`E1011:` There was a jinja2.TemplateSyntaxError error: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__)}``", + f"`E1011:` There was a jinja2.TemplateSyntaxError error: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__.tb_next)}``", ) logger.error(error_msg, extra={"object": obj}) raise NornirNautobotException(error_msg) 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)}`` and ``{str(exc.result.exception.__traceback__)}``" + error_msg = f"`E1012:` There was an issue finding the template and a jinja2.TemplateNotFound error was raised: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__.tb_lasti)}``" logger.error(error_msg, extra={"object": obj}) raise NornirNautobotException(error_msg) elif isinstance(exc.result.exception, jinja2.TemplateError): - error_msg = f"`E1013:` There was an issue general Jinja error: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__)}``" + error_msg = f"`E1013:` There was an issue general Jinja error: ``{str(exc.result.exception)}`` and ``{str(exc.result.exception.__traceback__.tb_lasti)}``" logger.error(error_msg, extra={"object": obj}) raise NornirNautobotException(error_msg)