diff --git a/lib/kubetruth/template.rb b/lib/kubetruth/template.rb index 1ac1744..51d66e8 100644 --- a/lib/kubetruth/template.rb +++ b/lib/kubetruth/template.rb @@ -193,14 +193,15 @@ def render(*args, **kwargs) result rescue Liquid::Error => e - msg = "Template failed to render:\n" - @source.lines.each {|l| msg << (INDENT * 2) << l } - msg << "\n" << INDENT << "with error message:\n" << (INDENT * 2) << "#{e.message}" + msg = "Template failed to render with error message:\n" + msg << (INDENT * 2) << e.message << "\n" if e.is_a?(Liquid::UndefinedVariable) - msg << "\n" << INDENT << "and variable context:\n" + msg << INDENT << "and variable context:\n" debug_kwargs ||= kwargs.merge(secrets: Hash[secrets.collect {|k, v| [k, ""] }]) debug_kwargs.deep_stringify_keys.to_yaml.lines.collect {|l| msg << (INDENT * 2) << l } end + msg << INDENT << "and template source:\n" + @source.lines.each {|l| msg << (INDENT * 2) << l } raise Error, msg end end