diff options
author | Jesse Rosenthal <jrosenthal@jhu.edu> | 2016-12-02 08:15:10 -0500 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-25 17:07:40 +0100 |
commit | 650fa2078890462f39be8fb294031bb706dbb5a0 (patch) | |
tree | ce03683c4b4276281f321efdc82010695a05fe04 /src/Text/Pandoc/Readers | |
parent | 9d69c51527bd9763a36e52b1995ddc9f79896f58 (diff) | |
download | pandoc-650fa2078890462f39be8fb294031bb706dbb5a0.tar.gz |
Readers: pass errors straight up to PandocMonad.
Since we've unified error types, we can just throw the same error at
the toplevel.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/MediaWiki.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Odt.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/TWiki.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Txt2Tags.hs | 3 |
8 files changed, 8 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 882777c0e..425e905f8 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -68,7 +68,7 @@ readLaTeX opts ltx = do parsed <- readWithM parseLaTeX def{ stateOptions = opts } ltx case parsed of Right result -> return result - Left _ -> throwError $ PandocParseError "parsing error" + Left e -> throwError e parseLaTeX :: PandocMonad m => LP m Pandoc parseLaTeX = do diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 0acfca980..b59e5a5f1 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -68,7 +68,6 @@ import Debug.Trace (trace) import Data.Monoid ((<>)) import Control.Monad.Trans (lift) import Control.Monad.Except (throwError, catchError) -import Text.Pandoc.Error import Text.Pandoc.Class (PandocMonad) import qualified Text.Pandoc.Class as P @@ -83,7 +82,7 @@ readMarkdown opts s = do parsed <- (readWithM parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n") case parsed of Right result -> return result - Left _ -> throwError $ PandocParseError "markdown parse error" + Left e -> throwError e -- | Read markdown from an input string and return a pair of a Pandoc document -- and a list of warnings. diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index e22e88bcb..5bdf0ca4e 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -58,7 +58,6 @@ import Data.Maybe (fromMaybe) import Text.Printf (printf) import Debug.Trace (trace) import Control.Monad.Except (throwError) -import Text.Pandoc.Error(PandocError(..)) import Text.Pandoc.Class (PandocMonad) -- | Read mediawiki from an input string and return a Pandoc document. @@ -77,7 +76,7 @@ readMediaWiki opts s = do (s ++ "\n") case parsed of Right result -> return result - Left _ -> throwError $ PandocParseError "problem parsing mediawiki" + Left e -> throwError e data MWState = MWState { mwOptions :: ReaderOptions , mwMaxNestingLevel :: Int diff --git a/src/Text/Pandoc/Readers/Odt.hs b/src/Text/Pandoc/Readers/Odt.hs index 9c8e76081..ac22f2c09 100644 --- a/src/Text/Pandoc/Readers/Odt.hs +++ b/src/Text/Pandoc/Readers/Odt.hs @@ -64,7 +64,7 @@ readOdt opts bytes = case readOdt' opts bytes of Right (doc, mb) -> do P.setMediaBag mb return doc - Left _ -> throwError $ PandocParseError "couldn't parse odt" + Left e -> throwError e -- readOdt' :: ReaderOptions diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index a20e29e93..078d2963c 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -51,7 +51,6 @@ import Data.Char (toLower, isHexDigit, isSpace) import Data.Monoid ((<>)) import Control.Monad.Except (throwError) import Control.Monad.Trans (lift) -import Text.Pandoc.Error import Text.Pandoc.Class (PandocMonad) import qualified Text.Pandoc.Class as P @@ -64,7 +63,7 @@ readRST opts s = do parsed <- (readWithM parseRST) def{ stateOptions = opts } (s ++ "\n\n") case parsed of Right result -> return result - Left _ -> throwError $ PandocParseError "error parsing rst" + Left e -> throwError e readRSTWithWarnings :: PandocMonad m => ReaderOptions -- ^ Reader options diff --git a/src/Text/Pandoc/Readers/TWiki.hs b/src/Text/Pandoc/Readers/TWiki.hs index 40ea8b75a..b2b136f39 100644 --- a/src/Text/Pandoc/Readers/TWiki.hs +++ b/src/Text/Pandoc/Readers/TWiki.hs @@ -60,7 +60,7 @@ readTWiki opts s = case readTWikiWithWarnings' opts s of Right (doc, warns) -> do mapM_ P.warn warns return doc - Left _ -> throwError $ PandocParseError "couldn't parse TWiki" + Left e -> throwError e readTWikiWithWarnings' :: ReaderOptions -- ^ Reader options -> String -- ^ String to parse (assuming @'\n'@ line endings) diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 4b558b42e..721b57f46 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -68,7 +68,6 @@ import Control.Monad ( guard, liftM, when ) import Data.Monoid ((<>)) import Text.Printf import Debug.Trace (trace) -import Text.Pandoc.Error import Text.Pandoc.Class (PandocMonad) import Control.Monad.Except (throwError) @@ -81,7 +80,7 @@ readTextile opts s = do parsed <- readWithM parseTextile def{ stateOptions = opts } (s ++ "\n\n") case parsed of Right result -> return result - Left _ -> throwError $ PandocParseError "textile parse error" + Left e -> throwError e -- | Generate a Pandoc ADT from a textile document diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs index 2769ecb42..4abe13827 100644 --- a/src/Text/Pandoc/Readers/Txt2Tags.hs +++ b/src/Text/Pandoc/Readers/Txt2Tags.hs @@ -50,7 +50,6 @@ 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.Error import Text.Pandoc.Class (PandocMonad) import qualified Text.Pandoc.Class as P @@ -99,7 +98,7 @@ readTxt2Tags opts s = do let parsed = flip runReader meta $ readWithM parseT2T (def {stateOptions = opts}) (s ++ "\n\n") case parsed of Right result -> return $ result - Left _ -> throwError $ PandocParseError "error parsing t2t" + Left e -> throwError e -- | Read Txt2Tags (ignoring all macros) from an input string returning -- a Pandoc document |