@@ -112,6 +112,7 @@ import Control.Arrow ((>>>), (&&&), arr)
112112import Control.Applicative ((<$>))
113113import Control.Monad.Reader (ask)
114114import Control.Monad.Trans (liftIO)
115+import Control.Monad.Error (throwError)
115116import Control.Category (Category, (.), id)
116117import Data.Maybe (fromMaybe)
117118import System.FilePath (takeExtension)
@@ -133,14 +134,14 @@ import Hakyll.Core.Logger
133134-- | Run a compiler, yielding the resulting target and it's dependencies. This
134135-- version of 'runCompilerJob' also stores the result
135136--
136−runCompiler :: Compiler () CompileRule -- ^ Compiler to run
137− -> Identifier -- ^ Target identifier
138− -> ResourceProvider -- ^ Resource provider
139− -> Routes -- ^ Route
140− -> Store -- ^ Store
141− -> Bool -- ^ Was the resource modified?
142− -> Logger -- ^ Logger
143− -> IO CompileRule -- ^ Resulting item
137+runCompiler :: Compiler () CompileRule -- ^ Compiler to run
138+ -> Identifier -- ^ Target identifier
139+ -> ResourceProvider -- ^ Resource provider
140+ -> Routes -- ^ Route
141+ -> Store -- ^ Store
142+ -> Bool -- ^ Was the resource modified?
143+ -> Logger -- ^ Logger
144+ -> IO (Throwing CompileRule) -- ^ Resulting item
144145runCompiler compiler identifier provider routes store modified logger = do
145146 -- Run the compiler job
146147 result <-
@@ -151,7 +152,7 @@ runCompiler compiler identifier provider routes store modified logger = do
151152 -- In case we compiled an item, we will store a copy in the cache first,
152153 -- before we return control. This makes sure the compiled item can later
153154 -- be accessed by e.g. require.
154− CompileRule (CompiledItem x) ->
155+ Right (CompileRule (CompiledItem x)) ->
155156 storeSet store "Hakyll.Core.Compiler.runCompiler" identifier x
156157
157158 -- Otherwise, we do nothing here
@@ -187,16 +188,16 @@ getResourceString = fromJob $ \resource -> CompilerM $ do
187188--
188189getDependency :: (Binary a, Writable a, Typeable a)
189190 => Identifier -> CompilerM a
190−getDependency identifier = CompilerM $ do
191+getDependency id' = CompilerM $ do
191192 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'
194+ case result of
195+ Nothing -> throwError error'
196+ Just x -> return x
194197 where
195− error' = error $ "Hakyll.Core.Compiler.getDependency: "
196− ++ show identifier
197− ++ " not found in the cache, the cache might be corrupted or"
198− ++ " the item you are referring to might not exist"
199−
198+ error' = "Hakyll.Core.Compiler.getDependency: " ++ show id'
199+ ++ " not found in the cache, the cache might be corrupted or"
200+ ++ " the item you are referring to might not exist"
200201
201202-- | Variant of 'require' which drops the current value
202203--