Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message when time is not parseable #1847

Merged
merged 1 commit into from
Dec 24, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/jekyll/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ def process(name)
self.slug = slug
self.ext = ext
rescue ArgumentError
raise FatalException.new("Post #{name} does not have a valid date.")
path = File.join(@dir || "", name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use #relative_path for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, when i change this we get a test failure:

[Jekyll::FatalException] exception expected, not
Class: <TypeError>
Message: <"no implicit conversion of nil into String">
---Backtrace---
/Users/schneems/Documents/projects/jekyll/lib/jekyll/post.rb:163:in `join'
/Users/schneems/Documents/projects/jekyll/lib/jekyll/post.rb:163:in `rescue in process'
/Users/schneems/Documents/projects/jekyll/lib/jekyll/post.rb:158:in `process'

Looks like @dir and @name can both be nil.

msg = "Post '#{path}' does not have a valid date.\n"
msg << "Fix the date, or exclude the file or directory from being processed"
raise FatalException.new(msg)
end

# The generated directory into which the post will be placed
Expand Down