aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-12-01 12:13:51 -0500
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:40 +0100
commit3574b98f81c2c24f7ef31f8251ba88792a2c06f0 (patch)
tree8bf439b943cf82d260fffd1d627db0608b1ef34f /src
parent52859b98632e991e94a3d37c0e0ae6c5d3b3fa34 (diff)
downloadpandoc-3574b98f81c2c24f7ef31f8251ba88792a2c06f0.tar.gz
Unify Errors.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc.hs4
-rw-r--r--src/Text/Pandoc/Class.hs41
-rw-r--r--src/Text/Pandoc/Error.hs26
-rw-r--r--src/Text/Pandoc/Parsing.hs2
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs3
-rw-r--r--src/Text/Pandoc/Readers/EPUB.hs3
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs3
-rw-r--r--src/Text/Pandoc/Readers/Haddock.hs5
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs4
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs3
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs3
-rw-r--r--src/Text/Pandoc/Readers/Native.hs2
-rw-r--r--src/Text/Pandoc/Readers/OPML.hs4
-rw-r--r--src/Text/Pandoc/Readers/Odt.hs6
-rw-r--r--src/Text/Pandoc/Readers/Org.hs3
-rw-r--r--src/Text/Pandoc/Readers/RST.hs3
-rw-r--r--src/Text/Pandoc/Readers/TWiki.hs2
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs3
-rw-r--r--src/Text/Pandoc/Readers/Txt2Tags.hs3
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs3
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs3
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs3
-rw-r--r--src/Text/Pandoc/Writers/Man.hs3
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs3
-rw-r--r--src/Text/Pandoc/Writers/OPML.hs3
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs3
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs3
27 files changed, 83 insertions, 64 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index a49d52e25..036d3cdf5 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -180,7 +180,7 @@ import Text.Pandoc.Templates
import Text.Pandoc.Options
import Text.Pandoc.Shared (safeRead, mapLeft, pandocVersion)
import Text.Pandoc.Error
-import Text.Pandoc.Class (PandocMonad, runIOorExplode, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad, runIOorExplode)
import Data.Aeson
import qualified Data.ByteString.Lazy as BL
import Data.List (intercalate)
@@ -387,7 +387,7 @@ class ToJSONFilter a => ToJsonFilter a
toJsonFilter = toJSONFilter
readJSON :: ReaderOptions -> String -> Either PandocError Pandoc
-readJSON _ = mapLeft ParseFailure . eitherDecode' . UTF8.fromStringLazy
+readJSON _ = mapLeft PandocParseError . eitherDecode' . UTF8.fromStringLazy
writeJSON :: WriterOptions -> Pandoc -> String
writeJSON _ = UTF8.toStringLazy . encode
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
index 12566a51c..b3bbc04bc 100644
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -39,7 +39,6 @@ module Text.Pandoc.Class ( PandocMonad(..)
, addWarningWithPos
, PandocIO(..)
, PandocPure(..)
- , PandocExecutionError(..)
, FileInfo(..)
, runIO
, runIOorExplode
@@ -83,12 +82,12 @@ import Control.Monad.State hiding (fail)
import Control.Monad.Reader hiding (fail)
import Control.Monad.Except hiding (fail)
import Data.Word (Word8)
-import Data.Typeable
import Data.Default
import System.IO.Error
import qualified Data.Map as M
+import Text.Pandoc.Error
-class (Functor m, Applicative m, Monad m, MonadError PandocExecutionError m) => PandocMonad m where
+class (Functor m, Applicative m, Monad m, MonadError PandocError m) => PandocMonad m where
lookupEnv :: String -> m (Maybe String)
getCurrentTime :: m UTCTime
getCurrentTimeZone :: m TimeZone
@@ -143,12 +142,6 @@ addWarningWithPos mbpos msg =
warn $
msg ++ maybe "" (\pos -> " " ++ show pos) mbpos
--- We can add to this as we go
-data PandocExecutionError = PandocFileReadError FilePath
- | PandocShouldNeverHappenError String
- | PandocParseError String
- | PandocSomeError String
- deriving (Show, Typeable)
-- Nothing in this for now, but let's put it there anyway.
data PandocStateIO = PandocStateIO { ioStWarnings :: [String]
@@ -168,35 +161,35 @@ instance Default PandocEnvIO where
, ioEnvOutputFile = Nothing -- stdout
}
-runIO :: PandocIO a -> IO (Either PandocExecutionError a)
+runIO :: PandocIO a -> IO (Either PandocError a)
runIO ma = flip evalStateT def $ flip runReaderT def $ runExceptT $ unPandocIO ma
withMediaBag :: PandocMonad m => m a -> m (a, MediaBag)
withMediaBag ma = ((,)) <$> ma <*> getMediaBag
runIOorExplode :: PandocIO a -> IO a
-runIOorExplode ma = do
- eitherVal <- runIO ma
- case eitherVal of
- Right x -> return x
- Left (PandocFileReadError fp) -> error $ "problem reading " ++ fp
- Left (PandocShouldNeverHappenError s) -> error s
- Left (PandocParseError s) -> error $ "parse error" ++ s
- Left (PandocSomeError s) -> error s
+runIOorExplode ma = handleError <$> runIO ma
+ -- eitherVal <- runIO ma
+ -- case eitherVal of
+ -- Right x -> return x
+ -- Left (PandocFileReadError fp) -> error $ "problem reading " ++ fp
+ -- Left (PandocShouldNeverHappenError s) -> error s
+ -- Left (PandocParseError s) -> error $ "parse error" ++ s
+ -- Left (PandocSomeError s) -> error s
newtype PandocIO a = PandocIO {
- unPandocIO :: ExceptT PandocExecutionError (ReaderT PandocEnvIO (StateT PandocStateIO IO)) a
+ unPandocIO :: ExceptT PandocError (ReaderT PandocEnvIO (StateT PandocStateIO IO)) a
} deriving ( MonadIO
, Functor
, Applicative
, Monad
, MonadReader PandocEnvIO
, MonadState PandocStateIO
- , MonadError PandocExecutionError
+ , MonadError PandocError
)
instance PandocMonad PandocIO where
@@ -303,20 +296,18 @@ instance Default PureEnv where
, envOutputFile = Nothing
}
-instance E.Exception PandocExecutionError
-
newtype PandocPure a = PandocPure {
- unPandocPure :: ExceptT PandocExecutionError
+ unPandocPure :: ExceptT PandocError
(ReaderT PureEnv (State PureState)) a
} deriving ( Functor
, Applicative
, Monad
, MonadReader PureEnv
, MonadState PureState
- , MonadError PandocExecutionError
+ , MonadError PandocError
)
-runPure :: PandocPure a -> Either PandocExecutionError a
+runPure :: PandocPure a -> Either PandocError a
runPure x = flip evalState def $ flip runReaderT def $ runExceptT $ unPandocPure x
instance PandocMonad PandocPure where
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index 5e26771fe..c001b279a 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -33,17 +33,24 @@ module Text.Pandoc.Error (PandocError(..), handleError) where
import Text.Parsec.Error
import Text.Parsec.Pos hiding (Line)
-import GHC.Generics (Generic)
import Data.Generics (Typeable)
import Control.Exception (Exception)
type Input = String
-data PandocError = -- | Generic parse failure
- ParseFailure String
- -- | Error thrown by a Parsec parser
- | ParsecError Input ParseError
- deriving (Show, Typeable, Generic)
+data PandocError = PandocFileReadError FilePath
+ | PandocShouldNeverHappenError String
+ | PandocSomeError String
+ | PandocParseError String
+ | PandocParsecError Input ParseError
+ deriving (Show, Typeable)
+
+
+-- data PandocError = -- | Generic parse failure
+-- ParseFailure String
+-- -- | Error thrown by a Parsec parser
+-- | ParsecError Input ParseError
+-- deriving (Show, Typeable, Generic)
instance Exception PandocError
@@ -52,8 +59,11 @@ handleError :: Either PandocError a -> a
handleError (Right r) = r
handleError (Left err) =
case err of
- ParseFailure string -> error string
- ParsecError input err' ->
+ PandocFileReadError fp -> error $ "problem reading " ++ fp
+ PandocShouldNeverHappenError s -> error s
+ PandocSomeError s -> error s
+ PandocParseError s -> error s
+ PandocParsecError input err' ->
let errPos = errorPos err'
errLine = sourceLine errPos
errColumn = sourceColumn errPos
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 90cc20ab6..796d09632 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -885,7 +885,7 @@ readWithM :: (Monad m)
-> String -- ^ input
-> m (Either PandocError a)
readWithM parser state input =
- mapLeft (ParsecError input) `liftM` runParserT parser state "source" input
+ mapLeft (PandocParsecError input) `liftM` runParserT parser state "source" input
-- | Parse a string with a given parser and state
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 87b64d544..37fe5c532 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -96,8 +96,9 @@ import qualified Data.Sequence as Seq (null)
#if !(MIN_VERSION_base(4,8,0))
import Data.Traversable (traverse)
#endif
+import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
readDocx :: PandocMonad m
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
index 0dbe87052..a76ed04ba 100644
--- a/src/Text/Pandoc/Readers/EPUB.hs
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -32,7 +32,8 @@ import Data.Maybe (mapMaybe, fromMaybe)
import qualified Data.Map as M (Map, lookup, fromList, elems)
import Data.Monoid ((<>))
import Control.DeepSeq (deepseq, NFData)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
import Debug.Trace (trace)
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index ef28ff739..b66a712e0 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -68,7 +68,8 @@ import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
import Data.Monoid ((<>))
import Text.Parsec.Error
import qualified Data.Set as Set
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import Control.Monad.Except (throwError)
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
index 4d33f657c..987342bf7 100644
--- a/src/Text/Pandoc/Readers/Haddock.hs
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -25,8 +25,9 @@ import Text.Pandoc.Options
import Documentation.Haddock.Parser
import Documentation.Haddock.Types
import Debug.Trace (trace)
+import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
-- | Parse Haddock markup and return a 'Pandoc' document.
@@ -40,7 +41,7 @@ readHaddock opts s = case readHaddockEither opts s of
readHaddockEither :: ReaderOptions -- ^ Reader options
-> String -- ^ String to parse
- -> Either PandocExecutionError Pandoc
+ -> Either PandocError Pandoc
readHaddockEither opts =
#if MIN_VERSION_haddock_library(1,2,0)
Right . B.doc . docHToBlocks . trace' . _doc . parseParas
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 2506c17be..882777c0e 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -57,7 +57,7 @@ import Text.Pandoc.Highlighting (fromListingsLanguage)
import Text.Pandoc.ImageSize (numUnit, showFl)
import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..), PandocPure)
+import Text.Pandoc.Class (PandocMonad, PandocPure)
-- | Parse LaTeX from string and return 'Pandoc' document.
readLaTeX :: PandocMonad m
@@ -939,7 +939,7 @@ type IncludeParser = ParserT String [String] IO String
-- | Replace "include" commands with file contents.
handleIncludes :: String -> IO (Either PandocError String)
-handleIncludes s = mapLeft (ParsecError s) <$> runParserT includeParser' [] "input" s
+handleIncludes s = mapLeft (PandocParsecError s) <$> runParserT includeParser' [] "input" s
includeParser' :: IncludeParser
includeParser' =
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index e5df065ff..0acfca980 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -68,7 +68,8 @@ import Debug.Trace (trace)
import Data.Monoid ((<>))
import Control.Monad.Trans (lift)
import Control.Monad.Except (throwError, catchError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
type MarkdownParser m = ParserT [Char] ParserState m
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index 7f45cdb2a..e22e88bcb 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -58,7 +58,8 @@ import Data.Maybe (fromMaybe)
import Text.Printf (printf)
import Debug.Trace (trace)
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error(PandocError(..))
+import Text.Pandoc.Class (PandocMonad)
-- | Read mediawiki from an input string and return a Pandoc document.
readMediaWiki :: PandocMonad m
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
index 489ddcd4a..3e934e43f 100644
--- a/src/Text/Pandoc/Readers/Native.hs
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -65,5 +65,5 @@ readInlines :: String -> Either PandocError [Inline]
readInlines s = maybe ((:[]) <$> readInline s) Right (safeRead s)
readInline :: String -> Either PandocError Inline
-readInline s = maybe (Left . ParseFailure $ "Could not read: " ++ s) Right (safeRead s)
+readInline s = maybe (Left . PandocParseError $ "Could not read: " ++ s) Right (safeRead s)
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
index 608e9ae0f..627566609 100644
--- a/src/Text/Pandoc/Readers/OPML.hs
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -13,7 +13,7 @@ import Control.Monad.State
import Data.Default
import Control.Monad.Except
import Text.Pandoc.Error
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
type OPML m = StateT OPMLState m
@@ -65,7 +65,7 @@ attrValue attr elt =
Just z -> z
Nothing -> ""
--- exceptT :: PandocMonad m => Either PandocExecutionError a -> OPML m a
+-- exceptT :: PandocMonad m => Either PandocError a -> OPML m a
-- exceptT = either throwError return
asHtml :: PandocMonad m => String -> OPML m Inlines
diff --git a/src/Text/Pandoc/Readers/Odt.hs b/src/Text/Pandoc/Readers/Odt.hs
index 898dda077..9c8e76081 100644
--- a/src/Text/Pandoc/Readers/Odt.hs
+++ b/src/Text/Pandoc/Readers/Odt.hs
@@ -41,7 +41,7 @@ import System.FilePath
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
import Text.Pandoc.Definition
import Text.Pandoc.Error
@@ -78,7 +78,7 @@ readOdt' _ bytes = bytesToOdt bytes-- of
bytesToOdt :: B.ByteString -> Either PandocError (Pandoc, MediaBag)
bytesToOdt bytes = case toArchiveOrFail bytes of
Right archive -> archiveToOdt archive
- Left _ -> Left $ ParseFailure "Couldn't parse odt file."
+ Left _ -> Left $ PandocParseError "Couldn't parse odt file."
--
archiveToOdt :: Archive -> Either PandocError (Pandoc, MediaBag)
@@ -99,7 +99,7 @@ archiveToOdt archive
| otherwise
-- Not very detailed, but I don't think more information would be helpful
- = Left $ ParseFailure "Couldn't parse odt file."
+ = Left $ PandocParseError "Couldn't parse odt file."
where
filePathIsOdtMedia :: FilePath -> Bool
filePathIsOdtMedia fp =
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 3a41ed317..c8dbbf45a 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -31,8 +31,9 @@ import Text.Pandoc.Readers.Org.Blocks ( blockList, meta )
import Text.Pandoc.Readers.Org.Parsing ( OrgParser, readWithM )
import Text.Pandoc.Readers.Org.ParserState ( optionsToParserState )
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
import Text.Pandoc.Definition
+import Text.Pandoc.Error
import Text.Pandoc.Options
import Control.Monad.Except ( throwError )
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 4232f1c90..a20e29e93 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -51,7 +51,8 @@ import Data.Char (toLower, isHexDigit, isSpace)
import Data.Monoid ((<>))
import Control.Monad.Except (throwError)
import Control.Monad.Trans (lift)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
-- | Parse reStructuredText string and return Pandoc document.
diff --git a/src/Text/Pandoc/Readers/TWiki.hs b/src/Text/Pandoc/Readers/TWiki.hs
index 091dcd7b1..40ea8b75a 100644
--- a/src/Text/Pandoc/Readers/TWiki.hs
+++ b/src/Text/Pandoc/Readers/TWiki.hs
@@ -48,7 +48,7 @@ import qualified Data.Foldable as F
import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
-- | Read twiki from an input string and return a Pandoc document.
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index 5494695f5..4b558b42e 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -68,7 +68,8 @@ import Control.Monad ( guard, liftM, when )
import Data.Monoid ((<>))
import Text.Printf
import Debug.Trace (trace)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import Control.Monad.Except (throwError)
-- | Parse a Textile text and return a Pandoc document.
diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs
index 29457ee6a..2769ecb42 100644
--- a/src/Text/Pandoc/Readers/Txt2Tags.hs
+++ b/src/Text/Pandoc/Readers/Txt2Tags.hs
@@ -50,7 +50,8 @@ import Control.Monad.Reader (Reader, runReader, asks)
import Data.Time.Format (formatTime)
import Text.Pandoc.Compat.Time (defaultTimeLocale)
import Control.Monad.Except (throwError, catchError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
type T2T = ParserT String ParserState (Reader T2TMeta)
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index f0dce739e..e41aa96ad 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -65,7 +65,8 @@ import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
import Text.HTML.TagSoup (Tag(TagOpen), fromAttrib, parseTags)
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
-- A Chapter includes a list of blocks and maybe a section
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
index 5c22c8586..2401d7eee 100644
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -46,7 +46,8 @@ import Text.Pandoc.Definition
import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,
linesToPara)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
-- | Data to be written at the end of the document:
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 4520708e4..4c8ccfe4a 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -69,7 +69,8 @@ import qualified Text.XML.Light as XML
import System.FilePath (takeExtension)
import Data.Aeson (Value)
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
data WriterState = WriterState
{ stNotes :: [Html] -- ^ List of notes
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index c9530e4e1..27cf22b41 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -41,8 +41,9 @@ import Data.Maybe (fromMaybe)
import Text.Pandoc.Pretty
import Text.Pandoc.Builder (deleteMeta)
import Control.Monad.State
+import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
type Notes = [[Block]]
data WriterState = WriterState { stNotes :: Notes
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 4c33de65d..092693ea4 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -58,7 +58,8 @@ import qualified Data.Vector as V
import qualified Data.Text as T
import qualified Data.Set as Set
import Network.HTTP ( urlEncode )
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
type Notes = [[Block]]
type Ref = ([Inline], Target, Attr)
diff --git a/src/Text/Pandoc/Writers/OPML.hs b/src/Text/Pandoc/Writers/OPML.hs
index dee3a029c..38c96589a 100644
--- a/src/Text/Pandoc/Writers/OPML.hs
+++ b/src/Text/Pandoc/Writers/OPML.hs
@@ -40,8 +40,9 @@ import Text.Pandoc.Writers.Markdown (writeMarkdown)
import Text.Pandoc.Pretty
import Text.Pandoc.Compat.Time
import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Error
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Class (PandocMonad)
-- | Convert Pandoc document to string in OPML format.
writeOPML :: PandocMonad m => WriterOptions -> Pandoc -> m String
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index 1ac906756..f5d56d021 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -44,7 +44,8 @@ import qualified Data.Map as M
import Text.Printf ( printf )
import Text.Pandoc.ImageSize
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class (PandocMonad, PandocExecutionError(..))
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
import qualified Text.Pandoc.Class as P
-- | Convert Image inlines into a raw RTF embedded image, read from a file,
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index 44a1fffd8..783a01063 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -45,7 +45,8 @@ import Network.URI ( isURI, unEscapeString )
import System.FilePath
import qualified Data.Set as Set
import Control.Monad.Except (throwError)
-import Text.Pandoc.Class ( PandocMonad, PandocExecutionError(..) )
+import Text.Pandoc.Error
+import Text.Pandoc.Class ( PandocMonad)
data WriterState =
WriterState { stStrikeout :: Bool -- document contains strikeout