summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2017-03-18 14:46:23 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2017-03-18 14:46:23 +0100
commit2577bd4bb267ba66141524000a235c000178ea72 (patch)
tree9baeade4c0166aa03589a6d9898157c960871c4d /src
parentfb999b32ee194756f9366bb85b4624ef21147ac3 (diff)
downloadhakyll-2577bd4bb267ba66141524000a235c000178ea72.tar.gz
Better error for `cached` on non-existing file
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Compiler.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs
index ae9fbf1..42b24d6 100644
--- a/src/Hakyll/Core/Compiler.hs
+++ b/src/Hakyll/Core/Compiler.hs
@@ -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)
@@ -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
@@ -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