From 7adf346d127d507d46f907b13c758c8f7bb7d038 Mon Sep 17 00:00:00 2001 From: Simon Heather <32168619+X-Guardian@users.noreply.github.com> Date: Fri, 20 Jan 2023 22:51:09 +0000 Subject: [PATCH] [Resolves #1267] Improve the Stack Config Jinja Error Message to include the Stack Name (#1269) Improves the stack config Jinja error message to include the stack name. ### Original Error Message ``` 'foo2' is undefined ``` ### New Error Message ``` dev/stack.yaml - 'foo2' is undefined ``` --- sceptre/config/reader.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sceptre/config/reader.py b/sceptre/config/reader.py index c225fc2c8..2bd664263 100644 --- a/sceptre/config/reader.py +++ b/sceptre/config/reader.py @@ -446,11 +446,17 @@ def _render(self, directory_path, basename, stack_group_config): ) from err self.templating_vars.update(stack_group_config) - rendered_template = template.render( - self.templating_vars, - command_path=self.context.command_path.split(path.sep), - environment_variable=environ, - ) + + try: + rendered_template = template.render( + self.templating_vars, + command_path=self.context.command_path.split(path.sep), + environment_variable=environ, + ) + except Exception as err: + raise SceptreException( + f"{Path(directory_path, basename).as_posix()} - {err}" + ) from err try: config = yaml.safe_load(rendered_template)