Rescue from Psych::SyntaxError instead of SyntaxError after parsing YAML (#5828)

Merge pull request 5828
This commit is contained in:
Jonathan Hooper 2017-11-22 08:37:18 -06:00 committed by jekyllbot
parent f6cf8b934a
commit 1c469eb53a
3 changed files with 4 additions and 4 deletions

View File

@ -46,7 +46,7 @@ module Jekyll
self.content = $POSTMATCH
self.data = SafeYAML.load(Regexp.last_match(1))
end
rescue SyntaxError => e
rescue Psych::SyntaxError => e
Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}"
raise e if self.site.config["strict_front_matter"]
rescue StandardError => e

View File

@ -266,7 +266,7 @@ module Jekyll
merge_defaults
read_content(opts)
read_post_data
rescue SyntaxError, StandardError, Errors::FatalException => e
rescue StandardError => e
handle_read_error(e)
end
end
@ -463,7 +463,7 @@ module Jekyll
private
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}"
else
Jekyll.logger.error "Error:", "could not read file #{path}: #{error.message}"

View File

@ -31,7 +31,7 @@ class TestConvertible < JekyllUnitTest
ret = @convertible.read_yaml(@base, name)
assert_equal({}, ret)
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)
end