@@ -28,7 +28,7 @@ module Hakyll.Core.Compiler
30--------------------------------------------------------------------------------
30--------------------------------------------------------------------------------
31−import Control.Monad (when)
31+import Control.Monad (when, unless)
32import Data.Binary (Binary)
32import Data.Binary (Binary)
33import Data.ByteString.Lazy (ByteString)
33import Data.ByteString.Lazy (ByteString)
34import Data.Typeable (Typeable)
34import Data.Typeable (Typeable)
@@ -149,6 +149,10 @@ cached name compiler = do
149 id' <- compilerUnderlying <$> compilerAsk
149 id' <- compilerUnderlying <$> compilerAsk
150 store <- compilerStore <$> compilerAsk
150 store <- compilerStore <$> compilerAsk
151 provider <- compilerProvider <$> compilerAsk
151 provider <- compilerProvider <$> compilerAsk
153+ -- Give a better error message when the resource is not there at all.
154+ unless (resourceExists provider id') $ fail $ itDoesntEvenExist id'
152 let modified = resourceModified provider id'
156 let modified = resourceModified provider id'
153 if modified
157 if modified
@@ -166,6 +170,11 @@ cached name compiler = do
166 "Hakyll.Core.Compiler.cached: Cache corrupt! " ++
170 "Hakyll.Core.Compiler.cached: Cache corrupt! " ++
167 "Try running: " ++ progName ++ " clean"
171 "Try running: " ++ progName ++ " clean"
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'
170--------------------------------------------------------------------------------
179--------------------------------------------------------------------------------
171unsafeCompiler :: IO a -> Compiler a
180unsafeCompiler :: IO a -> Compiler a