on master help sign in
Perform sanity check on returned Identifier
91da790Jasper Van der Jeugt
src/Hakyll/Core/Runtime.hs+11−5
@@ -6,7 +6,7 @@ module Hakyll.Core.Runtime
6
6
7--------------------------------------------------------------------------------
7--------------------------------------------------------------------------------
8import Control.Applicative ((<$>))
8import Control.Applicative ((<$>))
9−import Control.Monad (filterM)
9+import Control.Monad (filterM, unless)
10import Control.Monad.Error (ErrorT, runErrorT, throwError)
10import Control.Monad.Error (ErrorT, runErrorT, throwError)
11import Control.Monad.Reader (ask)
11import Control.Monad.Reader (ask)
12import Control.Monad.RWS (RWST, runRWST)
12import Control.Monad.RWS (RWST, runRWST)
@@ -27,6 +27,7 @@ import Hakyll.Core.Compiler.Require
27import Hakyll.Core.Configuration
27import Hakyll.Core.Configuration
28import Hakyll.Core.Dependencies
28import Hakyll.Core.Dependencies
29import Hakyll.Core.Identifier
29import Hakyll.Core.Identifier
30+import Hakyll.Core.Item
30import Hakyll.Core.Item.SomeItem
31import Hakyll.Core.Item.SomeItem
31import Hakyll.Core.Logger (Logger, Verbosity)
32import Hakyll.Core.Logger (Logger, Verbosity)
32import qualified Hakyll.Core.Logger as Logger
33import qualified Hakyll.Core.Logger as Logger
@@ -200,15 +201,20 @@ chase trail id'
200
201
201 -- Huge success
202 -- Huge success
202 CompilerDone (SomeItem item) cwrite -> do
203 CompilerDone (SomeItem item) cwrite -> do
203− -- TODO: Sanity check on itemIdentifier?
204+ -- Print some info
204− let facts = compilerDependencies cwrite
205+ let facts = compilerDependencies cwrite
205 cacheHits
206 cacheHits
206 | compilerCacheHits cwrite <= 0 = "updated"
207 | compilerCacheHits cwrite <= 0 = "updated"
207 | otherwise = "cached "
208 | otherwise = "cached "
208−
209− -- Print some info
210 Logger.message logger $ cacheHits ++ " " ++ show id'
209 Logger.message logger $ cacheHits ++ " " ++ show id'
211
210
211+ -- Sanity check
212+ unless (itemIdentifier item == id') $ throwError $
213+ "The compiler yielded an Item with Identifier " ++
214+ show (itemIdentifier item) ++ ", but we were expecting " ++
215+ "an Item with Identifier " ++ show id' ++ " " ++
216+ "(you probably want to call makeItem to solve this problem)"
217+
212 -- Write if necessary
218 -- Write if necessary
213 case runRoutes routes id' of
219 case runRoutes routes id' of
214 Nothing -> return ()
220 Nothing -> return ()