git.iko.soy/typeable/pandoc
on master help sign in
Readers: pass errors straight up to PandocMonad.

Since we've unified error types, we can just throw the same error at the toplevel.

commit650fa2078890462f39be8fb294031bb706dbb5a0 authorJesse Rosenthal <jrosenthal@jhu.edu> dateFri 2 Dec 2016, 08:15 (10 years ago) parent9d69c51
8 files changed+8−13
src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Readers/Markdown.hs+1−2 src/Text/Pandoc/Readers/MediaWiki.hs+1−2 src/Text/Pandoc/Readers/Odt.hs+1−1 src/Text/Pandoc/Readers/RST.hs+1−2 src/Text/Pandoc/Readers/TWiki.hs+1−1 src/Text/Pandoc/Readers/Textile.hs+1−2 src/Text/Pandoc/Readers/Txt2Tags.hs+1−2
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -68,7 +68,7 @@ readLaTeX opts ltx = do
6868 parsed <- readWithM parseLaTeX def{ stateOptions = opts } ltx
6969 case parsed of
7070 Right result -> return result
71− Left _ -> throwError $ PandocParseError "parsing error"
71+ Left e -> throwError e
7272
7373parseLaTeX :: PandocMonad m => LP m Pandoc
7474parseLaTeX = do
src/Text/Pandoc/Readers/Markdown.hs+1−2
@@ -68,7 +68,6 @@ import Debug.Trace (trace)
6868import Data.Monoid ((<>))
6969import Control.Monad.Trans (lift)
7070import Control.Monad.Except (throwError, catchError)
71−import Text.Pandoc.Error
7271import Text.Pandoc.Class (PandocMonad)
7372import qualified Text.Pandoc.Class as P
7473
@@ -83,7 +82,7 @@ readMarkdown opts s = do
8382 parsed <- (readWithM parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
8483 case parsed of
8584 Right result -> return result
86− Left _ -> throwError $ PandocParseError "markdown parse error"
85+ Left e -> throwError e
8786
8887-- | Read markdown from an input string and return a pair of a Pandoc document
8988-- and a list of warnings.
src/Text/Pandoc/Readers/MediaWiki.hs+1−2
@@ -58,7 +58,6 @@ import Data.Maybe (fromMaybe)
5858import Text.Printf (printf)
5959import Debug.Trace (trace)
6060import Control.Monad.Except (throwError)
61−import Text.Pandoc.Error(PandocError(..))
6261import Text.Pandoc.Class (PandocMonad)
6362
6463-- | Read mediawiki from an input string and return a Pandoc document.
@@ -77,7 +76,7 @@ readMediaWiki opts s = do
7776 (s ++ "\n")
7877 case parsed of
7978 Right result -> return result
80− Left _ -> throwError $ PandocParseError "problem parsing mediawiki"
79+ Left e -> throwError e
8180
8281data MWState = MWState { mwOptions :: ReaderOptions
8382 , mwMaxNestingLevel :: Int
src/Text/Pandoc/Readers/Odt.hs+1−1
@@ -64,7 +64,7 @@ readOdt opts bytes = case readOdt' opts bytes of
6464 Right (doc, mb) -> do
6565 P.setMediaBag mb
6666 return doc
67− Left _ -> throwError $ PandocParseError "couldn't parse odt"
67+ Left e -> throwError e
6868
6969--
7070readOdt' :: ReaderOptions
src/Text/Pandoc/Readers/RST.hs+1−2
@@ -51,7 +51,6 @@ import Data.Char (toLower, isHexDigit, isSpace)
5151import Data.Monoid ((<>))
5252import Control.Monad.Except (throwError)
5353import Control.Monad.Trans (lift)
54−import Text.Pandoc.Error
5554import Text.Pandoc.Class (PandocMonad)
5655import qualified Text.Pandoc.Class as P
5756
@@ -64,7 +63,7 @@ readRST opts s = do
6463 parsed <- (readWithM parseRST) def{ stateOptions = opts } (s ++ "\n\n")
6564 case parsed of
6665 Right result -> return result
67− Left _ -> throwError $ PandocParseError "error parsing rst"
66+ Left e -> throwError e
6867
6968readRSTWithWarnings :: PandocMonad m
7069 => ReaderOptions -- ^ Reader options
src/Text/Pandoc/Readers/TWiki.hs+1−1
@@ -60,7 +60,7 @@ readTWiki opts s = case readTWikiWithWarnings' opts s of
6060 Right (doc, warns) -> do
6161 mapM_ P.warn warns
6262 return doc
63− Left _ -> throwError $ PandocParseError "couldn't parse TWiki"
63+ Left e -> throwError e
6464
6565readTWikiWithWarnings' :: ReaderOptions -- ^ Reader options
6666 -> String -- ^ String to parse (assuming @'\n'@ line endings)
src/Text/Pandoc/Readers/Textile.hs+1−2
@@ -68,7 +68,6 @@ import Control.Monad ( guard, liftM, when )
6868import Data.Monoid ((<>))
6969import Text.Printf
7070import Debug.Trace (trace)
71−import Text.Pandoc.Error
7271import Text.Pandoc.Class (PandocMonad)
7372import Control.Monad.Except (throwError)
7473
@@ -81,7 +80,7 @@ readTextile opts s = do
8180 parsed <- readWithM parseTextile def{ stateOptions = opts } (s ++ "\n\n")
8281 case parsed of
8382 Right result -> return result
84− Left _ -> throwError $ PandocParseError "textile parse error"
83+ Left e -> throwError e
8584
8685
8786-- | Generate a Pandoc ADT from a textile document
src/Text/Pandoc/Readers/Txt2Tags.hs+1−2
@@ -50,7 +50,6 @@ import Control.Monad.Reader (Reader, runReader, asks)
5050import Data.Time.Format (formatTime)
5151import Text.Pandoc.Compat.Time (defaultTimeLocale)
5252import Control.Monad.Except (throwError, catchError)
53−import Text.Pandoc.Error
5453import Text.Pandoc.Class (PandocMonad)
5554import qualified Text.Pandoc.Class as P
5655
@@ -99,7 +98,7 @@ readTxt2Tags opts s = do
9998 let parsed = flip runReader meta $ readWithM parseT2T (def {stateOptions = opts}) (s ++ "\n\n")
10099 case parsed of
101100 Right result -> return $ result
102− Left _ -> throwError $ PandocParseError "error parsing t2t"
101+ Left e -> throwError e
103102
104103-- | Read Txt2Tags (ignoring all macros) from an input string returning
105104-- a Pandoc document