From e663bb0e1479dac2638a3e4f693e5eeac314e347 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 6 Oct 2022 10:51:05 +0200 Subject: [API Change] T.P.Error: Add new constructor "PandocFormatError" The new error is used to report problems with input or output format specifications. The use of PandocAppError is now limited to code in T.P.App and T.P.Citeproc. --- src/Text/Pandoc/Error.hs | 4 ++++ src/Text/Pandoc/Readers.hs | 3 +-- src/Text/Pandoc/Writers.hs | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs index c5ba2aa90..b53e39ca3 100644 --- a/src/Text/Pandoc/Error.hs +++ b/src/Text/Pandoc/Error.hs @@ -64,6 +64,7 @@ data PandocError = PandocIOError Text IOError | PandocUTF8DecodingError Text Int Word8 | PandocIpynbDecodingError Text | PandocUnsupportedCharsetError Text + | PandocFormatError Text Text | PandocUnknownReaderError Text | PandocUnknownWriterError Text | PandocUnsupportedExtensionError Text Text @@ -140,6 +141,8 @@ renderError e = "ipynb decoding error: " <> w PandocUnsupportedCharsetError charset -> "Unsupported charset " <> charset + PandocFormatError format s -> + "Error parsing format " <> tshow format <> ": " <> s PandocUnknownReaderError r -> "Unknown input format " <> r <> case r of @@ -181,6 +184,7 @@ handleError (Left e) = PandocAppError{} -> 4 PandocTemplateError{} -> 5 PandocOptionError{} -> 6 + PandocFormatError{} -> 20 PandocUnknownReaderError{} -> 21 PandocUnknownWriterError{} -> 22 PandocUnsupportedExtensionError{} -> 23 diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs index 7abd1d024..eef455627 100644 --- a/src/Text/Pandoc/Readers.hs +++ b/src/Text/Pandoc/Readers.hs @@ -166,8 +166,7 @@ readers = [("native" , TextReader readNative) getReader :: PandocMonad m => Text -> m (Reader m, Extensions) getReader s = case parseFormatSpec s of - Left e -> throwError $ PandocAppError $ - "Error parsing reader format " <> tshow s <> ": " <> tshow e + Left e -> throwError $ PandocFormatError 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 f4e1f9040..385f1352f 100644 --- a/src/Text/Pandoc/Writers.hs +++ b/src/Text/Pandoc/Writers.hs @@ -196,8 +196,7 @@ writers = [ getWriter :: PandocMonad m => Text -> m (Writer m, Extensions) getWriter s = case parseFormatSpec s of - Left e -> throwError $ PandocAppError $ - "Error parsing writer format " <> tshow s <> ": " <> tshow e + Left e -> throwError $ PandocFormatError s (tshow e) Right (writerName, extsToEnable, extsToDisable) -> case lookup writerName writers of Nothing -> throwError $ -- cgit v1.2.3