Skip to content

Commit

Permalink
Merge pull request #2649 from alfredxing/friendly-date-error
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Aug 2, 2014
2 parents ea7e895 + 989d5d3 commit e75dc74
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/jekyll/post.rb
Expand Up @@ -61,7 +61,14 @@ def initialize(site, source, dir, name)
end

if data.key?('date')
self.date = Time.parse(data["date"].to_s)
begin
self.date = Time.parse(data["date"].to_s)
rescue ArgumentError
path = File.join(@dir || "", name)
msg = "Post '#{relative_path}' does not have a valid date in the YAML front matter.\n"
msg << "Fix the date, or exclude the file or directory from being processed"
raise Errors::FatalException.new(msg)
end
end

populate_categories
Expand Down Expand Up @@ -166,7 +173,7 @@ def process(name)
self.ext = ext
rescue ArgumentError
path = File.join(@dir || "", name)
msg = "Post '#{path}' does not have a valid date.\n"
msg = "Post '#{relative_path}' does not have a valid date.\n"
msg << "Fix the date, or exclude the file or directory from being processed"
raise Errors::FatalException.new(msg)
end
Expand Down

0 comments on commit e75dc74

Please sign in to comment.