git.iko.soy/typeable/pandoc
on master help sign in
Replace some more fails with throwErrors.
commit63a1e05dd1eb041aee55a5c5c4d0d84a035348b2 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 28 Sep 2019, 13:42 (7 years ago) parentdf74eea
3 files changed+9−4
src/Text/Pandoc/Writers/Docx.hs+5−2 src/Text/Pandoc/Writers/Muse.hs+2−1 src/Text/Pandoc/Writers/Powerpoint/Output.hs+2−1
src/Text/Pandoc/Writers/Docx.hs+5−2
@@ -3,6 +3,7 @@
33{-# LANGUAGE RankNTypes #-}
44{-# LANGUAGE ScopedTypeVariables #-}
55{-# LANGUAGE ViewPatterns #-}
6+{-# LANGUAGE FlexibleContexts #-}
67{-# LANGUAGE OverloadedStrings #-}
78{- |
89 Module : Text.Pandoc.Writers.Docx
@@ -19,7 +20,7 @@ module Text.Pandoc.Writers.Docx ( writeDocx ) where
1920import Prelude
2021import Codec.Archive.Zip
2122import Control.Applicative ((<|>))
22−import Control.Monad.Except (catchError)
23+import Control.Monad.Except (catchError, throwError)
2324import Control.Monad.Reader
2425import Control.Monad.State.Strict
2526import qualified Data.ByteString as B
@@ -43,6 +44,7 @@ import Text.Pandoc.UTF8 (fromStringLazy)
4344import Text.Pandoc.Definition
4445import Text.Pandoc.Generic
4546import Text.Pandoc.Highlighting (highlight)
47+import Text.Pandoc.Error
4648import Text.Pandoc.ImageSize
4749import Text.Pandoc.Logging
4850import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType,
@@ -580,7 +582,8 @@ writeDocx opts doc@(Pandoc meta _) = do
580582 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
581583
582584 let entryFromArchive arch path =
583− maybe (Prelude.fail $ path ++ " missing in reference docx")
585+ maybe (throwError $ PandocSomeError
586+ $ path ++ " missing in reference docx")
584587 return
585588 (findEntryByPath path arch `mplus` findEntryByPath path distArchive)
586589 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
src/Text/Pandoc/Writers/Muse.hs+2−1
@@ -620,7 +620,8 @@ inlineToMuse (Quoted DoubleQuote lst) = do
620620 modify $ \st -> st { stUseTags = False }
621621 return $ "“" <> contents <> "”"
622622inlineToMuse Cite {} =
623− Prelude.fail "Citations should be expanded before normalization"
623+ throwError $ PandocShouldNeverHappenError
624+ $ "Citations should be expanded before normalization"
624625inlineToMuse (Code _ str) = do
625626 useTags <- gets stUseTags
626627 modify $ \st -> st { stUseTags = False }
src/Text/Pandoc/Writers/Powerpoint/Output.hs+2−1
@@ -173,7 +173,8 @@ copyFileToArchive arch fp = do
173173 refArchive <- asks envRefArchive
174174 distArchive <- asks envDistArchive
175175 case findEntryByPath fp refArchive `mplus` findEntryByPath fp distArchive of
176− Nothing -> Prelude.fail $ fp ++ " missing in reference file"
176+ Nothing -> throwError $ PandocSomeError
177+ $ fp ++ " missing in reference file"
177178 Just e -> return $ addEntryToArchive e arch
178179
179180alwaysInheritedPatterns :: [Pattern]