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