From 182ad87ad353280c522bdda272c70ac9cdefae3e Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 24 May 2012 14:04:25 -0700 Subject: [PATCH] Catch Psych::SyntaxError. Related to #446 --- .../lib/middleman-core/core_extensions/front_matter.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index d9c5175f..aff3f443 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -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] @@ -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