Skip to content

Commit

Permalink
Better error message for invalid post date.
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Mar 12, 2011
1 parent 6c94db1 commit dce4ccc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion bin/jekyll
Expand Up @@ -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}"
Expand Down
2 changes: 2 additions & 0 deletions lib/jekyll/post.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/test_post.rb
Expand Up @@ -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")
Expand Down

0 comments on commit dce4ccc

Please sign in to comment.