mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-26 10:16:32 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user