diff --git a/History.txt b/History.txt index 99d7da604b9..bbc08d74d80 100644 --- a/History.txt +++ b/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 diff --git a/bin/jekyll b/bin/jekyll index 4a2f7a32365..c025a62341a 100755 --- a/bin/jekyll +++ b/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}" diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 8c866fe4d1f..5502994ceac 100644 --- a/lib/jekyll/post.rb +++ b/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 diff --git a/test/test_post.rb b/test/test_post.rb index b93c587368f..c4a5db127c6 100644 --- a/test/test_post.rb +++ b/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")