From 91da7902518e7a1eb5a386408a53ef04d19e3de6 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 7 Jan 2013 21:59:23 +0100 Subject: Perform sanity check on returned Identifier --- src/Hakyll/Core/Runtime.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/Hakyll') diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs index 4755a6a..cb0813b 100644 --- a/src/Hakyll/Core/Runtime.hs +++ b/src/Hakyll/Core/Runtime.hs @@ -6,7 +6,7 @@ module Hakyll.Core.Runtime -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) -import Control.Monad (filterM) +import Control.Monad (filterM, unless) import Control.Monad.Error (ErrorT, runErrorT, throwError) import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) @@ -27,6 +27,7 @@ import Hakyll.Core.Compiler.Require import Hakyll.Core.Configuration import Hakyll.Core.Dependencies import Hakyll.Core.Identifier +import Hakyll.Core.Item import Hakyll.Core.Item.SomeItem import Hakyll.Core.Logger (Logger, Verbosity) import qualified Hakyll.Core.Logger as Logger @@ -200,15 +201,20 @@ chase trail id' -- Huge success CompilerDone (SomeItem item) cwrite -> do - -- TODO: Sanity check on itemIdentifier? - let facts = compilerDependencies cwrite + -- Print some info + let facts = compilerDependencies cwrite cacheHits | compilerCacheHits cwrite <= 0 = "updated" | otherwise = "cached " - - -- Print some info Logger.message logger $ cacheHits ++ " " ++ show id' + -- Sanity check + unless (itemIdentifier item == id') $ throwError $ + "The compiler yielded an Item with Identifier " ++ + show (itemIdentifier item) ++ ", but we were expecting " ++ + "an Item with Identifier " ++ show id' ++ " " ++ + "(you probably want to call makeItem to solve this problem)" + -- Write if necessary case runRoutes routes id' of Nothing -> return () -- cgit v1.2.3