Skip to content
Browse files

Better error message for invalid post date.

  • Loading branch information...
1 parent 6c94db1 commit dce4ccc5a445af75b3da5012d8bb49d05da0ca11 @mojombo mojombo committed Mar 11, 2011
Showing with 15 additions and 1 deletion.
  1. +2 −0 History.txt
  2. +5 −1 bin/jekyll
  3. +2 −0 lib/jekyll/post.rb
  4. +6 −0 test/test_post.rb
View
2 History.txt
@@ -7,6 +7,8 @@
* Use English library to avoid hoops (#292)
* Add Posterous importer (#254)
* Fixes for Wordpress importer (#274, #252, #271)
+ * Better error message for invalid post date (#291)
+ * Print formatted fatal exceptions to stdout on build failure
* Bug Fixes
* Secure additional path exploits
View
6 bin/jekyll
@@ -242,7 +242,11 @@ else
puts "Building site: #{source} -> #{destination}"
begin
site.process
- rescue Jekyll::FatalException
+ rescue Jekyll::FatalException => e
+ puts
+ puts "ERROR: YOUR SITE COULD NOT BE BUILT:"
+ puts "------------------------------------"
+ puts e.message
exit(1)
end
puts "Successfully generated site: #{source} -> #{destination}"
View
2 lib/jekyll/post.rb
@@ -78,6 +78,8 @@ def process(name)
self.date = Time.parse(date)
self.slug = slug
self.ext = ext
+ rescue ArgumentError
+ raise FatalException.new("Post #{name} does not have a valid date.")
end
# The generated directory into which the post will be placed
View
6 test/test_post.rb
@@ -52,6 +52,12 @@ def do_render(post)
assert_equal "/2008/09/09/foo-bar.html", @post.url
end
+ should "raise a good error on invalid post date" do
+ assert_raise Jekyll::FatalException do
+ @post.process("2009-27-03-foo-bar.textile")
+ end
+ end
+
should "CGI escape urls" do
@post.categories = []
@post.process("2009-03-12-hash-#1.markdown")

0 comments on commit dce4ccc

Please sign in to comment.
Something went wrong with that request. Please try again.