Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Making sure errors don't halt the import.

Wrapped file operations in a begin/rescue block.
  • Loading branch information...
commit 20ac62d30ec6434f5afa1f0c193ed158abd4f082 1 parent fa8400a
Fabio Neves authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/jekyll/migrators/wordpressdotcom.rb
View
17 lib/jekyll/migrators/wordpressdotcom.rb
@@ -52,11 +52,18 @@ def self.process(filename = "wordpress.xml")
'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
Please sign in to comment.
Something went wrong with that request. Please try again.