git.iko.soy/typeable/pandoc
on master help sign in
Docx Reader: Throw PandocError on unzip failure
91dc334Jesse Rosenthal
src/Text/Pandoc/Readers/Docx.hs+5−4
@@ -100,12 +100,13 @@ import Text.Pandoc.Compat.Except
100readDocxWithWarnings :: ReaderOptions
100readDocxWithWarnings :: ReaderOptions
101 -> B.ByteString
101 -> B.ByteString
102 -> Either PandocError (Pandoc, MediaBag, [String])
102 -> Either PandocError (Pandoc, MediaBag, [String])
103−readDocxWithWarnings opts bytes =
103+readDocxWithWarnings opts bytes
104− case archiveToDocxWithWarnings (toArchive bytes) of
104+ | Right archive <- toArchiveOrFail bytes
105− Right (docx, warnings) -> do
105+ , Right (docx, warnings) <- archiveToDocxWithWarnings archive = do
106 (meta, blks, mediaBag) <- docxToOutput opts docx
106 (meta, blks, mediaBag) <- docxToOutput opts docx
107 return (Pandoc meta blks, mediaBag, warnings)
107 return (Pandoc meta blks, mediaBag, warnings)
108+readDocxWithWarnings _ _ =
108− Left _ -> Left (ParseFailure "couldn't parse docx file")
109+ Left (ParseFailure "couldn't parse docx file")
109
110
110readDocx :: ReaderOptions
111readDocx :: ReaderOptions
111 -> B.ByteString
112 -> B.ByteString