Make PandocExecutionError an exception
Until we fix fetchItem and fetchItem' to make use of MonadError, we have to thow an exception. We'll throw PandocFileReadError. Note that this is temporary.
This commit is contained in:
parent
211d0f9574
commit
b2721c6b02
1 changed files with 3 additions and 6 deletions
|
@ -105,7 +105,7 @@ getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime
|
||||||
|
|
||||||
-- We can add to this as we go
|
-- We can add to this as we go
|
||||||
data PandocExecutionError = PandocFileReadError String
|
data PandocExecutionError = PandocFileReadError String
|
||||||
deriving Show
|
deriving (Show, Typeable)
|
||||||
|
|
||||||
-- Nothing in this for now, but let's put it there anyway.
|
-- Nothing in this for now, but let's put it there anyway.
|
||||||
data PandocStateIO = PandocStateIO
|
data PandocStateIO = PandocStateIO
|
||||||
|
@ -174,10 +174,7 @@ data TestEnv = TestEnv { envEnv :: [(String, String)]
|
||||||
, envFontFiles :: [FilePath]
|
, envFontFiles :: [FilePath]
|
||||||
}
|
}
|
||||||
|
|
||||||
data TestException = TestException
|
instance E.Exception PandocExecutionError
|
||||||
deriving (Show, Typeable)
|
|
||||||
|
|
||||||
instance E.Exception TestException
|
|
||||||
|
|
||||||
newtype PandocPure a = PandocPure {
|
newtype PandocPure a = PandocPure {
|
||||||
unPandocPure :: ExceptT PandocExecutionError
|
unPandocPure :: ExceptT PandocExecutionError
|
||||||
|
@ -230,7 +227,7 @@ instance PandocMonad PandocPure where
|
||||||
fps <- asks envFiles
|
fps <- asks envFiles
|
||||||
case lookup fp fps of
|
case lookup fp fps of
|
||||||
Just bs -> return (Right (bs, getMimeType fp))
|
Just bs -> return (Right (bs, getMimeType fp))
|
||||||
Nothing -> return (Left $ E.toException TestException)
|
Nothing -> return (Left $ E.toException $ PandocFileReadError "oops")
|
||||||
|
|
||||||
fetchItem' media sourceUrl nm = do
|
fetchItem' media sourceUrl nm = do
|
||||||
case lookupMedia nm media of
|
case lookupMedia nm media of
|
||||||
|
|
Loading…
Add table
Reference in a new issue