diff --git a/dbt_common/clients/jinja.py b/dbt_common/clients/jinja.py index cb136a3..8cc1205 100644 --- a/dbt_common/clients/jinja.py +++ b/dbt_common/clients/jinja.py @@ -46,6 +46,7 @@ MaterializationArgError, JinjaRenderingError, UndefinedCompilationError, + DbtRuntimeError, ) from dbt_common.exceptions.macros import MacroReturn, UndefinedMacroError, CaughtMacroError @@ -534,7 +535,11 @@ def catch_jinja(node: Optional[_NodeProtocol] = None) -> Iterator[None]: except CompilationError as exc: exc.add_node(node) raise + except DbtRuntimeError: + # Propagate dbt exception raised during jinja compilation + raise except Exception as e: + # Raise any non-dbt exceptions as CompilationError raise CompilationError(str(e), node) from e