Making sure errors don't halt the import.
Wrapped file operations in a begin/rescue block.
This commit is contained in:
parent
fa8400ab61
commit
20ac62d30e
|
@ -52,12 +52,19 @@ module Jekyll
|
||||||
'meta' => metas
|
'meta' => metas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
begin
|
||||||
FileUtils.mkdir_p "_#{type}s"
|
FileUtils.mkdir_p "_#{type}s"
|
||||||
File.open("_#{type}s/#{name}", "w") do |f|
|
File.open("_#{type}s/#{name}", "w") do |f|
|
||||||
f.puts header.to_yaml
|
f.puts header.to_yaml
|
||||||
f.puts '---'
|
f.puts '---'
|
||||||
f.puts item.at('content:encoded').inner_text
|
f.puts item.at('content:encoded').inner_text
|
||||||
end
|
end
|
||||||
|
rescue
|
||||||
|
puts "Couldn't import post!"
|
||||||
|
puts "Title: #{title}"
|
||||||
|
puts "Name/Slug: #{name}\n"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
import_count[type] += 1
|
import_count[type] += 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue