From da3aa16c8bffe896082288902256b4454e9dc415 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 19 May 2011 00:41:39 +0200 Subject: Better error messages for type errors --- src/Hakyll/Core/Compiler.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/Hakyll/Core/Compiler.hs') diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index 5ef3256..2164dda 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -217,16 +217,18 @@ getDependency id' = CompilerM $ do store <- compilerStore <$> ask result <- liftIO $ storeGet store "Hakyll.Core.Compiler.runCompiler" id' case result of - NotFound -> throwError notFound - WrongType -> throwError wrongType - Found x -> return x + NotFound -> throwError notFound + WrongType e r -> throwError $ wrongType e r + Found x -> return x where - notFound = "Hakyll.Core.Compiler.getDependency: " ++ show id' - ++ " not found in the cache, the cache might be corrupted or" - ++ " the item you are referring to might not exist" - wrongType = "Hakyll.Core.Compiler.getDependency: " ++ show id' - ++ " was found in the cache, but does not have the expected " - ++ " type" + notFound = + "Hakyll.Core.Compiler.getDependency: " ++ show id' ++ " not found " ++ + "not found in the cache, the cache might be corrupted or " ++ + "the item you are referring to might not exist" + wrongType e r = + "Hakyll.Core.Compiler.getDependency: " ++ show id' ++ " was found " ++ + "in the cache, but does not have the right type: expected " ++ show e ++ + " but got " ++ show r -- | Variant of 'require' which drops the current value -- -- cgit v1.2.3