diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-05-01 12:17:12 -0400 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-05-01 12:17:12 -0400 |
commit | 91dc334249883b658e2b91fce80ced6635e07c28 (patch) | |
tree | b9585bcc11216d566d8a20101649b44886a9fccd /src | |
parent | aa4a1d527a3ecbc291a70a872f06fa7a525d8e39 (diff) | |
download | pandoc-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')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 9 |
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 |