Skip to content

Commit

Permalink
Better error for cached on non-existing file
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Mar 18, 2017
1 parent fb999b3 commit 2577bd4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Hakyll/Core/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Hakyll.Core.Compiler


--------------------------------------------------------------------------------
import Control.Monad (when)
import Control.Monad (when, unless)
import Data.Binary (Binary)
import Data.ByteString.Lazy (ByteString)
import Data.Typeable (Typeable)
Expand Down Expand Up @@ -149,6 +149,10 @@ cached name compiler = do
id' <- compilerUnderlying <$> compilerAsk
store <- compilerStore <$> compilerAsk
provider <- compilerProvider <$> compilerAsk

-- Give a better error message when the resource is not there at all.
unless (resourceExists provider id') $ fail $ itDoesntEvenExist id'

let modified = resourceModified provider id'
if modified
then do
Expand All @@ -166,6 +170,11 @@ cached name compiler = do
"Hakyll.Core.Compiler.cached: Cache corrupt! " ++
"Try running: " ++ progName ++ " clean"

itDoesntEvenExist id' =
"Hakyll.Core.Compiler.cached: You are trying to (perhaps " ++
"indirectly) use `cached` on a non-existing resource: there " ++
"is no file backing " ++ show id'


--------------------------------------------------------------------------------
unsafeCompiler :: IO a -> Compiler a
Expand Down

0 comments on commit 2577bd4

Please sign in to comment.