Rescue from Psych::SyntaxError instead of SyntaxError after parsing YAML (#5828)
Merge pull request 5828
This commit is contained in:
parent
f6cf8b934a
commit
1c469eb53a
|
@ -46,7 +46,7 @@ module Jekyll
|
||||||
self.content = $POSTMATCH
|
self.content = $POSTMATCH
|
||||||
self.data = SafeYAML.load(Regexp.last_match(1))
|
self.data = SafeYAML.load(Regexp.last_match(1))
|
||||||
end
|
end
|
||||||
rescue SyntaxError => e
|
rescue Psych::SyntaxError => e
|
||||||
Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
|
Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
|
||||||
raise e if self.site.config["strict_front_matter"]
|
raise e if self.site.config["strict_front_matter"]
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
|
|
|
@ -266,7 +266,7 @@ module Jekyll
|
||||||
merge_defaults
|
merge_defaults
|
||||||
read_content(opts)
|
read_content(opts)
|
||||||
read_post_data
|
read_post_data
|
||||||
rescue SyntaxError, StandardError, Errors::FatalException => e
|
rescue StandardError => e
|
||||||
handle_read_error(e)
|
handle_read_error(e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -463,7 +463,7 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
def handle_read_error(error)
|
def handle_read_error(error)
|
||||||
if error.is_a? SyntaxError
|
if error.is_a? Psych::SyntaxError
|
||||||
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}"
|
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}"
|
||||||
else
|
else
|
||||||
Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}"
|
Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}"
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TestConvertible < JekyllUnitTest
|
||||||
ret = @convertible.read_yaml(@base, name)
|
ret = @convertible.read_yaml(@base, name)
|
||||||
assert_equal({}, ret)
|
assert_equal({}, ret)
|
||||||
end
|
end
|
||||||
assert_match(%r!YAML Exception|syntax error|Error reading file!, out)
|
assert_match(%r!YAML Exception!, out)
|
||||||
assert_match(%r!#{File.join(@base, name)}!, out)
|
assert_match(%r!#{File.join(@base, name)}!, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue