git.iko.soy/typeable/pandoc
on master help sign in
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.

commit16d372abcb991caf26077c7f1cd0be4680894170 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 19 Apr 2021, 08:38 (5 years ago) parent73d394c
2 files changed+6−6
src/Text/Pandoc/Readers.hs+3−3 src/Text/Pandoc/Writers.hs+3−3
src/Text/Pandoc/Readers.hs+3−3
@@ -65,6 +65,7 @@ import Data.Aeson
6565import qualified Data.ByteString.Lazy as BL
6666import Data.Text (Text)
6767import qualified Data.Text as T
68+import Text.Pandoc.Shared (tshow)
6869import Text.Pandoc.Class
6970import Text.Pandoc.Definition
7071import Text.Pandoc.Error
@@ -101,7 +102,6 @@ import Text.Pandoc.Readers.CSV
101102import Text.Pandoc.Readers.CslJson
102103import Text.Pandoc.Readers.BibTeX
103104import qualified Text.Pandoc.UTF8 as UTF8
104−import Text.Parsec.Error
105105
106106data Reader m = TextReader (ReaderOptions -> Text -> m Pandoc)
107107 | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc)
@@ -152,8 +152,8 @@ readers = [ ("native" , TextReader readNative)
152152getReader :: PandocMonad m => Text -> m (Reader m, Extensions)
153153getReader s =
154154 case parseFormatSpec s of
155− Left e -> throwError $ PandocAppError
156− $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e]
155+ Left e -> throwError $ PandocAppError $
156+ "Error parsing reader format " <> tshow s <> ": " <> tshow e
157157 Right (readerName, extsToEnable, extsToDisable) ->
158158 case lookup readerName readers of
159159 Nothing -> throwError $ PandocUnknownReaderError
src/Text/Pandoc/Writers.hs+3−3
@@ -81,6 +81,7 @@ import Data.Aeson
8181import qualified Data.ByteString.Lazy as BL
8282import Data.Text (Text)
8383import qualified Data.Text as T
84+import Text.Pandoc.Shared (tshow)
8485import Text.Pandoc.Class
8586import Text.Pandoc.Definition
8687import Text.Pandoc.Options
@@ -122,7 +123,6 @@ import Text.Pandoc.Writers.Texinfo
122123import Text.Pandoc.Writers.Textile
123124import Text.Pandoc.Writers.XWiki
124125import Text.Pandoc.Writers.ZimWiki
125−import Text.Parsec.Error
126126
127127data Writer m = TextWriter (WriterOptions -> Pandoc -> m Text)
128128 | ByteStringWriter (WriterOptions -> Pandoc -> m BL.ByteString)
@@ -196,8 +196,8 @@ writers = [
196196getWriter :: PandocMonad m => Text -> m (Writer m, Extensions)
197197getWriter s =
198198 case parseFormatSpec s of
199− Left e -> throwError $ PandocAppError
200− $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e]
199+ Left e -> throwError $ PandocAppError $
200+ "Error parsing writer format " <> tshow s <> ": " <> tshow e
201201 Right (writerName, extsToEnable, extsToDisable) ->
202202 case lookup writerName writers of
203203 Nothing -> throwError $