@@ -112,6 +112,7 @@ import Control.Arrow ((>>>), (&&&), arr)
112import Control.Applicative ((<$>))
112import Control.Applicative ((<$>))
113import Control.Monad.Reader (ask)
113import Control.Monad.Reader (ask)
114import Control.Monad.Trans (liftIO)
114import Control.Monad.Trans (liftIO)
115+import Control.Monad.Error (throwError)
115import Control.Category (Category, (.), id)
116import Control.Category (Category, (.), id)
116import Data.Maybe (fromMaybe)
117import Data.Maybe (fromMaybe)
117import System.FilePath (takeExtension)
118import System.FilePath (takeExtension)
@@ -133,14 +134,14 @@ import Hakyll.Core.Logger
133-- | Run a compiler, yielding the resulting target and it's dependencies. This
134-- | Run a compiler, yielding the resulting target and it's dependencies. This
134-- version of 'runCompilerJob' also stores the result
135-- version of 'runCompilerJob' also stores the result
136−runCompiler :: Compiler () CompileRule -- ^ Compiler to run
137+runCompiler :: Compiler () CompileRule -- ^ Compiler to run
137− -> Identifier -- ^ Target identifier
138+ -> Identifier -- ^ Target identifier
138− -> ResourceProvider -- ^ Resource provider
139+ -> ResourceProvider -- ^ Resource provider
139− -> Routes -- ^ Route
140+ -> Routes -- ^ Route
140− -> Store -- ^ Store
141+ -> Store -- ^ Store
141− -> Bool -- ^ Was the resource modified?
142+ -> Bool -- ^ Was the resource modified?
142− -> Logger -- ^ Logger
143+ -> Logger -- ^ Logger
143− -> IO CompileRule -- ^ Resulting item
144+ -> IO (Throwing CompileRule) -- ^ Resulting item
144runCompiler compiler identifier provider routes store modified logger = do
145runCompiler compiler identifier provider routes store modified logger = do
145 -- Run the compiler job
146 -- Run the compiler job
146 result <-
147 result <-
@@ -151,7 +152,7 @@ runCompiler compiler identifier provider routes store modified logger = do
151 -- In case we compiled an item, we will store a copy in the cache first,
152 -- In case we compiled an item, we will store a copy in the cache first,
152 -- before we return control. This makes sure the compiled item can later
153 -- before we return control. This makes sure the compiled item can later
153 -- be accessed by e.g. require.
154 -- be accessed by e.g. require.
154− CompileRule (CompiledItem x) ->
155+ Right (CompileRule (CompiledItem x)) ->
155 storeSet store "Hakyll.Core.Compiler.runCompiler" identifier x
156 storeSet store "Hakyll.Core.Compiler.runCompiler" identifier x
157 -- Otherwise, we do nothing here
158 -- Otherwise, we do nothing here
@@ -187,16 +188,16 @@ getResourceString = fromJob $ \resource -> CompilerM $ do
188getDependency :: (Binary a, Writable a, Typeable a)
189getDependency :: (Binary a, Writable a, Typeable a)
189 => Identifier -> CompilerM a
190 => Identifier -> CompilerM a
190−getDependency identifier = CompilerM $ do
191+getDependency id' = CompilerM $ do
191 store <- compilerStore <$> ask
192 store <- compilerStore <$> ask
192− fmap (fromMaybe error') $ liftIO $
193− storeGet store "Hakyll.Core.Compiler.runCompiler" identifier
193+ result <- liftIO $ storeGet store "Hakyll.Core.Compiler.runCompiler" id'
195+ Nothing -> throwError error'
195− error' = error $ "Hakyll.Core.Compiler.getDependency: "
198+ error' = "Hakyll.Core.Compiler.getDependency: " ++ show id'
197− ++ " not found in the cache, the cache might be corrupted or"
199+ ++ " not found in the cache, the cache might be corrupted or"
198− ++ " the item you are referring to might not exist"
200+ ++ " the item you are referring to might not exist"
201-- | Variant of 'require' which drops the current value
202-- | Variant of 'require' which drops the current value