From 623fa14b3c60e582602681b295f95519e1a4f0f3 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Tue, 1 Oct 2013 22:54:39 +0200 Subject: [PATCH 1/2] Include tag: provide path in case of render error --- lib/jekyll/tags/include.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index e359dae4..a16889d6 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -1,5 +1,14 @@ module Jekyll module Tags + class IncludeTagError < StandardError + attr_accessor :path + + def initialize(msg, path) + super msg + @path = path + end + end + class IncludeTag < Liquid::Tag SYNTAX_EXAMPLE = "{% include file.ext param='value' param2='value' %}" @@ -86,7 +95,11 @@ eos context.stack do context['include'] = parse_params(context) if @params - partial.render(context) + begin + partial.render!(context) + rescue => e + raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file) + end end end From 7a4ea086a1ed983ab49b9e3052ebd43c33929599 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Tue, 1 Oct 2013 23:02:50 +0200 Subject: [PATCH 2/2] Output path in case of render error in included file Fixes #1591. --- lib/jekyll/convertible.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 44bd8b9a..b1dacf59 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -86,6 +86,9 @@ module Jekyll # Returns the converted content def render_liquid(content, payload, info) Liquid::Template.parse(content).render!(payload, info) + rescue Tags::IncludeTagError => e + Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}" + raise e rescue Exception => e Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{self.path}" raise e