aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-05-01 12:17:12 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2016-05-01 12:17:12 -0400
commit91dc334249883b658e2b91fce80ced6635e07c28 (patch)
treeb9585bcc11216d566d8a20101649b44886a9fccd /src/Text/Pandoc/Readers
parentaa4a1d527a3ecbc291a70a872f06fa7a525d8e39 (diff)
downloadpandoc-91dc334249883b658e2b91fce80ced6635e07c28.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 604bc20de..9c7c3b264 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -100,12 +100,13 @@ import Text.Pandoc.Compat.Except
readDocxWithWarnings :: ReaderOptions
-> B.ByteString
-> Either PandocError (Pandoc, MediaBag, [String])
-readDocxWithWarnings opts bytes =
- case archiveToDocxWithWarnings (toArchive bytes) of
- Right (docx, warnings) -> do
+readDocxWithWarnings opts bytes
+ | Right archive <- toArchiveOrFail bytes
+ , Right (docx, warnings) <- archiveToDocxWithWarnings archive = do
(meta, blks, mediaBag) <- docxToOutput opts docx
return (Pandoc meta blks, mediaBag, warnings)
- Left _ -> Left (ParseFailure "couldn't parse docx file")
+readDocxWithWarnings _ _ =
+ Left (ParseFailure "couldn't parse docx file")
readDocx :: ReaderOptions
-> B.ByteString