-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Conversation
Give the full path of the file that cannot be parsed so the user can locate it easier. Follow up the error message with helpful instructions: they can resolve the error by fixing the date or excluding the file or directory from being processed.
This is awesome! Thanks for taking the time to make up this PR. Would you mind writing a quick test in |
We're exercising that code here https://github.com/schneems/jekyll/blob/schneems/better-bat-time-error/test/test_post.rb?pr=%2Fjekyll%2Fjekyll%2Fpull%2F1847#L56-L58 This is mostly a messaging change, so the same error test should be sufficient. On a side note, it looks like the
|
Any additional comments here? Should I change something, or should we close this PR? |
Know why the exception string is being prevented from being multi-line? Does it break a spec for how exceptions should be presented? Otherwise, looks awesome to me. |
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Give the full path of the file that cannot be parsed so the user can locate it easier. Follow up the error message with helpful instructions: they can resolve the error by fixing the date or excluding the file or directory from being processed.
Won't solve #1844 but will maybe help point in the right direction.