Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

output including file for include tag error #1746

Merged
merged 2 commits into from

3 participants

@maul-esel

Title sums it up pretty much.

Fixes #1745.

@parkr parkr commented on the diff
lib/jekyll/convertible.rb
@@ -87,7 +87,7 @@ def converter
def render_liquid(content, payload, info, path = nil)
Liquid::Template.parse(content).render!(payload, info)
rescue Tags::IncludeTagError => e
- Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}"
+ Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || self.path}"
raise e
rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}"
@parkr Owner
parkr added a note

Why do we use e.path above, but not here?

Because e.path only exists for Tags::IncludeTagError exceptions, where it references the file the error occured in. Other exceptions represent errors in the convertible's file itself, thus self.path (or path for rendering of layouts).

@parkr Owner
parkr added a note

Thanks for the explanation. :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maul-esel

Looking at the tag and @benbalter's issue again, there's something else wrong here. In IncludeTag#render, the rescue clause should not be for the whole method. I'll fix that asap.

@maul-esel maul-esel restrict rescue-clause in IncludeTag#render
As it previously enclosed the whole method, it also
wrapped file validation errors, which is not meant to be.

Fixes #1745.
c5533e9
@mattr-
Owner

Cool. Thanks! :heart:

@mattr- mattr- merged commit 7cb44fd into from
@mattr- mattr- referenced this pull request from a commit
@mattr- mattr- Update history to reflect merge of #1746 33be5b0
@maul-esel maul-esel deleted the branch
@gregkare gregkare referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@csim csim referenced this pull request from a commit in csim/jekyll
@mattr- mattr- Update history to reflect merge of #1746 73047ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 21, 2013
  1. @maul-esel
Commits on Nov 22, 2013
  1. @maul-esel

    restrict rescue-clause in IncludeTag#render

    maul-esel authored
    As it previously enclosed the whole method, it also
    wrapped file validation errors, which is not meant to be.
    
    Fixes #1745.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 7 deletions.
  1. +1 −1  lib/jekyll/convertible.rb
  2. +8 −6 lib/jekyll/tags/include.rb
View
2  lib/jekyll/convertible.rb
@@ -87,7 +87,7 @@ def converter
def render_liquid(content, payload, info, path = nil)
Liquid::Template.parse(content).render!(payload, info)
rescue Tags::IncludeTagError => e
- Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}"
+ Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || self.path}"
raise e
rescue Exception => e
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}"
@parkr Owner
parkr added a note

Why do we use e.path above, but not here?

Because e.path only exists for Tags::IncludeTagError exceptions, where it references the file the error occured in. Other exceptions represent errors in the convertible's file itself, thus self.path (or path for rendering of layouts).

@parkr Owner
parkr added a note

Thanks for the explanation. :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
14 lib/jekyll/tags/include.rb
@@ -96,14 +96,16 @@ def render(context)
path = File.join(dir, file)
validate_file(path, context.registers[:site].safe)
- partial = Liquid::Template.parse(source(path, context))
+ begin
+ partial = Liquid::Template.parse(source(path, context))
- context.stack do
- context['include'] = parse_params(context) if @params
- partial.render!(context)
+ context.stack do
+ context['include'] = parse_params(context) if @params
+ partial.render!(context)
+ end
+ rescue => e
+ raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file)
end
- rescue => e
- raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file)
end
def validate_dir(dir, safe)
Something went wrong with that request. Please try again.