diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-04-19 08:38:31 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-04-19 08:38:31 -0700 |
commit | 16d372abcb991caf26077c7f1cd0be4680894170 (patch) | |
tree | 8b384f635b89ae742e71490df1cbb5cbedaa0506 /src/Text/Pandoc | |
parent | 73d394ca2adff31a384404ae25665b36c7d0bba0 (diff) | |
download | pandoc-16d372abcb991caf26077c7f1cd0be4680894170.tar.gz |
Issue error message when reader or writer format is malformed.
Previously we exited with an error status but (due to a bug)
no message.
Closes #7231.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers.hs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs index ac70f7d4c..7ae9db34f 100644 --- a/src/Text/Pandoc/Readers.hs +++ b/src/Text/Pandoc/Readers.hs @@ -65,6 +65,7 @@ import Data.Aeson import qualified Data.ByteString.Lazy as BL import Data.Text (Text) import qualified Data.Text as T +import Text.Pandoc.Shared (tshow) import Text.Pandoc.Class import Text.Pandoc.Definition import Text.Pandoc.Error @@ -101,7 +102,6 @@ import Text.Pandoc.Readers.CSV import Text.Pandoc.Readers.CslJson import Text.Pandoc.Readers.BibTeX import qualified Text.Pandoc.UTF8 as UTF8 -import Text.Parsec.Error data Reader m = TextReader (ReaderOptions -> Text -> m Pandoc) | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc) @@ -152,8 +152,8 @@ readers = [ ("native" , TextReader readNative) getReader :: PandocMonad m => Text -> m (Reader m, Extensions) getReader s = case parseFormatSpec s of - Left e -> throwError $ PandocAppError - $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e] + Left e -> throwError $ PandocAppError $ + "Error parsing reader format " <> tshow s <> ": " <> tshow e Right (readerName, extsToEnable, extsToDisable) -> case lookup readerName readers of Nothing -> throwError $ PandocUnknownReaderError diff --git a/src/Text/Pandoc/Writers.hs b/src/Text/Pandoc/Writers.hs index 95d6270b5..c348477c2 100644 --- a/src/Text/Pandoc/Writers.hs +++ b/src/Text/Pandoc/Writers.hs @@ -81,6 +81,7 @@ import Data.Aeson import qualified Data.ByteString.Lazy as BL import Data.Text (Text) import qualified Data.Text as T +import Text.Pandoc.Shared (tshow) import Text.Pandoc.Class import Text.Pandoc.Definition import Text.Pandoc.Options @@ -122,7 +123,6 @@ import Text.Pandoc.Writers.Texinfo import Text.Pandoc.Writers.Textile import Text.Pandoc.Writers.XWiki import Text.Pandoc.Writers.ZimWiki -import Text.Parsec.Error data Writer m = TextWriter (WriterOptions -> Pandoc -> m Text) | ByteStringWriter (WriterOptions -> Pandoc -> m BL.ByteString) @@ -196,8 +196,8 @@ writers = [ getWriter :: PandocMonad m => Text -> m (Writer m, Extensions) getWriter s = case parseFormatSpec s of - Left e -> throwError $ PandocAppError - $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e] + Left e -> throwError $ PandocAppError $ + "Error parsing writer format " <> tshow s <> ": " <> tshow e Right (writerName, extsToEnable, extsToDisable) -> case lookup writerName writers of Nothing -> throwError $ |