@@ -28,7 +28,7 @@ module Hakyll.Core.Compiler
2828
2929
3030--------------------------------------------------------------------------------
31−import Control.Monad (when)
31+import Control.Monad (when, unless)
3232import Data.Binary (Binary)
3333import Data.ByteString.Lazy (ByteString)
3434import Data.Typeable (Typeable)
@@ -149,6 +149,10 @@ cached name compiler = do
149149 id' <- compilerUnderlying <$> compilerAsk
150150 store <- compilerStore <$> compilerAsk
151151 provider <- compilerProvider <$> compilerAsk
152+
153+ -- Give a better error message when the resource is not there at all.
154+ unless (resourceExists provider id') $ fail $ itDoesntEvenExist id'
155+
152156 let modified = resourceModified provider id'
153157 if modified
154158 then do
@@ -166,6 +170,11 @@ cached name compiler = do
166170 "Hakyll.Core.Compiler.cached: Cache corrupt! " ++
167171 "Try running: " ++ progName ++ " clean"
168172
173+ itDoesntEvenExist id' =
174+ "Hakyll.Core.Compiler.cached: You are trying to (perhaps " ++
175+ "indirectly) use `cached` on a non-existing resource: there " ++
176+ "is no file backing " ++ show id'
177+
169178
170179--------------------------------------------------------------------------------
171180unsafeCompiler :: IO a -> Compiler a