lib/epubinfo/parser.rb in epubinfo-0.3.3 vs lib/epubinfo/parser.rb in epubinfo-0.3.4

- old
+ new

@@ -17,14 +17,22 @@ end private def zip_file - @zip_file ||= Zip::ZipFile.open(@path) + begin + @zip_file ||= Zip::ZipFile.open(@path) + rescue Zip::ZipError => e + raise NotAnEPUBFileError.new(e) + end end def root_document - @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) + begin + @root_document ||= Nokogiri::XML(zip_file.read('META-INF/container.xml')) + rescue => e + raise NotAnEPUBFileError.new(e) + end end def metadata_path root_document.css('container rootfiles rootfile:first-child').attribute('full-path').content end