git.iko.soy/typeable/pandoc
on master help sign in
Replace some more fails with throwErrors.
63a1e05John MacFarlane
src/Text/Pandoc/Writers/Docx.hs+5−2
@@ -3,6 +3,7 @@
3{-# LANGUAGE RankNTypes #-}
3{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ViewPatterns #-}
5{-# LANGUAGE ViewPatterns #-}
6+{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE OverloadedStrings #-}
7{-# LANGUAGE OverloadedStrings #-}
7{- |
8{- |
8 Module : Text.Pandoc.Writers.Docx
9 Module : Text.Pandoc.Writers.Docx
@@ -19,7 +20,7 @@ module Text.Pandoc.Writers.Docx ( writeDocx ) where
19import Prelude
20import Prelude
20import Codec.Archive.Zip
21import Codec.Archive.Zip
21import Control.Applicative ((<|>))
22import Control.Applicative ((<|>))
22−import Control.Monad.Except (catchError)
23+import Control.Monad.Except (catchError, throwError)
23import Control.Monad.Reader
24import Control.Monad.Reader
24import Control.Monad.State.Strict
25import Control.Monad.State.Strict
25import qualified Data.ByteString as B
26import qualified Data.ByteString as B
@@ -43,6 +44,7 @@ import Text.Pandoc.UTF8 (fromStringLazy)
43import Text.Pandoc.Definition
44import Text.Pandoc.Definition
44import Text.Pandoc.Generic
45import Text.Pandoc.Generic
45import Text.Pandoc.Highlighting (highlight)
46import Text.Pandoc.Highlighting (highlight)
47+import Text.Pandoc.Error
46import Text.Pandoc.ImageSize
48import Text.Pandoc.ImageSize
47import Text.Pandoc.Logging
49import Text.Pandoc.Logging
48import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType,
50import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType,
@@ -580,7 +582,8 @@ writeDocx opts doc@(Pandoc meta _) = do
580 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
582 settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
581
583
582 let entryFromArchive arch path =
584 let entryFromArchive arch path =
585+ maybe (throwError $ PandocSomeError
583− maybe (Prelude.fail $ path ++ " missing in reference docx")
586+ $ path ++ " missing in reference docx")
584 return
587 return
585 (findEntryByPath path arch `mplus` findEntryByPath path distArchive)
588 (findEntryByPath path arch `mplus` findEntryByPath path distArchive)
586 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
589 docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
src/Text/Pandoc/Writers/Muse.hs+2−1
@@ -620,7 +620,8 @@ inlineToMuse (Quoted DoubleQuote lst) = do
620 modify $ \st -> st { stUseTags = False }
620 modify $ \st -> st { stUseTags = False }
621 return $ "“" <> contents <> "”"
621 return $ "“" <> contents <> "”"
622inlineToMuse Cite {} =
622inlineToMuse Cite {} =
623+ throwError $ PandocShouldNeverHappenError
623− Prelude.fail "Citations should be expanded before normalization"
624+ $ "Citations should be expanded before normalization"
624inlineToMuse (Code _ str) = do
625inlineToMuse (Code _ str) = do
625 useTags <- gets stUseTags
626 useTags <- gets stUseTags
626 modify $ \st -> st { stUseTags = False }
627 modify $ \st -> st { stUseTags = False }
src/Text/Pandoc/Writers/Powerpoint/Output.hs+2−1
@@ -173,7 +173,8 @@ copyFileToArchive arch fp = do
173 refArchive <- asks envRefArchive
173 refArchive <- asks envRefArchive
174 distArchive <- asks envDistArchive
174 distArchive <- asks envDistArchive
175 case findEntryByPath fp refArchive `mplus` findEntryByPath fp distArchive of
175 case findEntryByPath fp refArchive `mplus` findEntryByPath fp distArchive of
176+ Nothing -> throwError $ PandocSomeError
176− Nothing -> Prelude.fail $ fp ++ " missing in reference file"
177+ $ fp ++ " missing in reference file"
177 Just e -> return $ addEntryToArchive e arch
178 Just e -> return $ addEntryToArchive e arch
178
179
179alwaysInheritedPatterns :: [Pattern]
180alwaysInheritedPatterns :: [Pattern]