Catch Psych::SyntaxError. Related to #446

This commit is contained in:
Thomas Reynolds 2012-05-24 14:04:25 -07:00
parent bb659bb5be
commit 182ad87ad3

View file

@ -67,6 +67,12 @@ module Middleman::CoreExtensions
@cache.delete(path)
end
YAML_ERRORS = [ Exception, ArgumentError ]
if defined?(Psych) && defined?(Psych::SyntaxError)
YAML_ERRORS << Psych::SyntaxError
end
# Parse YAML frontmatter out of a string
# @param [String] content
# @return [Array<Hash, String>]
@ -77,7 +83,7 @@ module Middleman::CoreExtensions
begin
data = YAML.load($1)
rescue => e
rescue *YAML_ERRORS => e
puts "YAML Exception: #{e.message}"
return false
end