mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-31 01:38:24 -05:00
Add friendly error message for invalid dates
Catch the `ArgumentError` when parsing dates from the YAML front matter
This commit is contained in:
@@ -61,7 +61,14 @@ module Jekyll
|
||||
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 '#{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
|
||||
|
||||
Reference in New Issue
Block a user