diff options
| author | Albert Krewinkel <[email protected]> | 2022-10-06 10:51:05 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-10-08 16:05:48 -0700 |
| commit | e663bb0e1479dac2638a3e4f693e5eeac314e347 (patch) | |
| tree | 5ebdb0c16eac6b6f8bfc14bee412fcbf59c553f0 /src | |
| parent | 429606d5da6e2438f7f634f307ef33f795f7aa43 (diff) | |
[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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Error.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers.hs | 3 | ||||
| -rw-r--r-- | 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 $ |
