From 20ac62d30ec6434f5afa1f0c193ed158abd4f082 Mon Sep 17 00:00:00 2001 From: Fabio Neves Date: Sun, 11 Nov 2012 23:28:10 -0500 Subject: [PATCH] Making sure errors don't halt the import. Wrapped file operations in a begin/rescue block. --- lib/jekyll/migrators/wordpressdotcom.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/migrators/wordpressdotcom.rb b/lib/jekyll/migrators/wordpressdotcom.rb index 701c2af4..85762f89 100644 --- a/lib/jekyll/migrators/wordpressdotcom.rb +++ b/lib/jekyll/migrators/wordpressdotcom.rb @@ -52,11 +52,18 @@ module Jekyll 'meta' => metas } - FileUtils.mkdir_p "_#{type}s" - File.open("_#{type}s/#{name}", "w") do |f| - f.puts header.to_yaml - f.puts '---' - f.puts item.at('content:encoded').inner_text + begin + FileUtils.mkdir_p "_#{type}s" + File.open("_#{type}s/#{name}", "w") do |f| + f.puts header.to_yaml + f.puts '---' + f.puts item.at('content:encoded').inner_text + end + rescue + puts "Couldn't import post!" + puts "Title: #{title}" + puts "Name/Slug: #{name}\n" + next end import_count[type] += 1