aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-05-02 16:00:04 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-05-02 16:00:04 +0200
commitcd2551c16c1da0404b8de182f17160aebb69219d (patch)
treeb6e959c06a95cfb8f8ae1b9ea5ac4c2ac78dacea /src/Text/Pandoc/Class.hs
parent022d58e02a6276aa830639ad641aae1542731bbe (diff)
downloadpandoc-cd2551c16c1da0404b8de182f17160aebb69219d.tar.gz
Added PandocResourceNotFound error.
Use this instead of PandocIOError when a resource is not found in path. This improves the error message in this case, see #3629.
Diffstat (limited to 'src/Text/Pandoc/Class.hs')
-rw-r--r--src/Text/Pandoc/Class.hs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
index 1afa64c10..ad9901125 100644
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -330,8 +330,7 @@ downloadOrRead sourceURL s = do
convertSlash x = x
withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a
-withPaths [] _ fp = throwError $ PandocIOError fp
- (userError "file not found in resource path")
+withPaths [] _ fp = throwError $ PandocResourceNotFound fp
withPaths (p:ps) action fp =
catchError (action (p </> fp))
(\_ -> withPaths ps action fp)
@@ -433,20 +432,17 @@ instance PandocMonad PandocPure where
modifyPureState $ \st -> st { stUniqStore = us }
return u
_ -> M.fail "uniq store ran out of elements"
- openURL u = throwError $ PandocIOError u $
- userError "Cannot open URL in PandocPure"
+ openURL u = throwError $ PandocResourceNotFound u
readFileLazy fp = do
fps <- getsPureState stFiles
case infoFileContents <$> getFileInfo fp fps of
Just bs -> return (BL.fromStrict bs)
- Nothing -> throwError $ PandocIOError fp
- (userError "File not found in PureState")
+ Nothing -> throwError $ PandocResourceNotFound fp
readFileStrict fp = do
fps <- getsPureState stFiles
case infoFileContents <$> getFileInfo fp fps of
Just bs -> return bs
- Nothing -> throwError $ PandocIOError fp
- (userError "File not found in PureState")
+ Nothing -> throwError $ PandocResourceNotFound fp
readDataFile Nothing "reference.docx" = do
(B.concat . BL.toChunks . fromArchive) <$> getsPureState stReferenceDocx
readDataFile Nothing "reference.odt" = do