git.iko.soy/typeable/pandoc
on master help sign in
Docx Reader: Throw PandocError on unzip failure

Previously, readDocx would error out if zip-archive failed. We change the archive extraction step from `toArchive` to `toArchiveOrFail`, which returns an Either value.

commit91dc334249883b658e2b91fce80ced6635e07c28 authorJesse Rosenthal <jrosenthal@jhu.edu> dateSun 1 May 2016, 12:17 (10 years ago) parentaa4a1d5
1 file changed+5−4
src/Text/Pandoc/Readers/Docx.hs+5−4
src/Text/Pandoc/Readers/Docx.hs+5−4
@@ -100,12 +100,13 @@ import Text.Pandoc.Compat.Except
100100readDocxWithWarnings :: ReaderOptions
101101 -> B.ByteString
102102 -> Either PandocError (Pandoc, MediaBag, [String])
103−readDocxWithWarnings opts bytes =
104− case archiveToDocxWithWarnings (toArchive bytes) of
105− Right (docx, warnings) -> do
103+readDocxWithWarnings opts bytes
104+ | Right archive <- toArchiveOrFail bytes
105+ , Right (docx, warnings) <- archiveToDocxWithWarnings archive = do
106106 (meta, blks, mediaBag) <- docxToOutput opts docx
107107 return (Pandoc meta blks, mediaBag, warnings)
108− Left _ -> Left (ParseFailure "couldn't parse docx file")
108+readDocxWithWarnings _ _ =
109+ Left (ParseFailure "couldn't parse docx file")
109110
110111readDocx :: ReaderOptions
111112 -> B.ByteString