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.
This commit is contained in:
parent
aa4a1d527a
commit
91dc334249
1 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue