git.iko.soy/typeable/pandoc
on master help sign in
Make PandocExecutionError an exception
b2721c6Jesse Rosenthal
src/Text/Pandoc/Class.hs+3−6
@@ -105,7 +105,7 @@ getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime
105
105
106-- We can add to this as we go
106-- We can add to this as we go
107data PandocExecutionError = PandocFileReadError String
107data PandocExecutionError = PandocFileReadError String
108− deriving Show
108+ deriving (Show, Typeable)
109
109
110-- Nothing in this for now, but let's put it there anyway.
110-- Nothing in this for now, but let's put it there anyway.
111data PandocStateIO = PandocStateIO
111data PandocStateIO = PandocStateIO
@@ -174,10 +174,7 @@ data TestEnv = TestEnv { envEnv :: [(String, String)]
174 , envFontFiles :: [FilePath]
174 , envFontFiles :: [FilePath]
175 }
175 }
176
176
177−data TestException = TestException
178− deriving (Show, Typeable)
179−
180−instance E.Exception TestException
177+instance E.Exception PandocExecutionError
181
178
182newtype PandocPure a = PandocPure {
179newtype PandocPure a = PandocPure {
183 unPandocPure :: ExceptT PandocExecutionError
180 unPandocPure :: ExceptT PandocExecutionError
@@ -230,7 +227,7 @@ instance PandocMonad PandocPure where
230 fps <- asks envFiles
227 fps <- asks envFiles
231 case lookup fp fps of
228 case lookup fp fps of
232 Just bs -> return (Right (bs, getMimeType fp))
229 Just bs -> return (Right (bs, getMimeType fp))
233− Nothing -> return (Left $ E.toException TestException)
230+ Nothing -> return (Left $ E.toException $ PandocFileReadError "oops")
234
231
235 fetchItem' media sourceUrl nm = do
232 fetchItem' media sourceUrl nm = do
236 case lookupMedia nm media of
233 case lookupMedia nm media of