@@ -28,6 +28,7 @@ module Hakyll.Core.Compiler.Internal
2828import Control.Applicative (Alternative (..),
2929 Applicative (..), (<$>))
3030import Control.Exception (SomeException, handle)
31+import Control.Monad (forM_)
3132import Data.Monoid (Monoid (..))
3233import Data.Set (Set)
3334import qualified Data.Set as S
@@ -38,7 +39,8 @@ import Hakyll.Core.Configuration
3839import Hakyll.Core.Dependencies
3940import Hakyll.Core.Identifier
4041import Hakyll.Core.Identifier.Pattern
41−import Hakyll.Core.Logger
42+import Hakyll.Core.Logger (Logger)
43+import qualified Hakyll.Core.Logger as Logger
4244import Hakyll.Core.Metadata
4345import Hakyll.Core.Provider
4446import Hakyll.Core.Routes
@@ -82,7 +84,7 @@ instance Monoid CompilerWrite where
8284--------------------------------------------------------------------------------
8385data CompilerResult a where
8486 CompilerDone :: a -> CompilerWrite -> CompilerResult a
85− CompilerError :: String -> CompilerResult a
87+ CompilerError :: [String] -> CompilerResult a
8688 CompilerRequire :: Identifier -> Compiler a -> CompilerResult a
8789
8890
@@ -126,7 +128,7 @@ instance Monad Compiler where
126128 CompilerRequire i c' -> return $ CompilerRequire i $ c' >>= f
127129 {-# INLINE (>>=) #-}
128130
129− fail = compilerThrow
131+ fail = compilerThrow . return
130132 {-# INLINE fail #-}
131133
132134
@@ -150,13 +152,17 @@ runCompiler :: Compiler a -> CompilerRead -> IO (CompilerResult a)
150152runCompiler compiler read' = handle handler $ unCompiler compiler read'
151153 where
152154 handler :: SomeException -> IO (CompilerResult a)
153− handler e = return $ CompilerError $ show e
155+ handler e = return $ CompilerError [show e]
154156
155157
156158--------------------------------------------------------------------------------
157159instance Alternative Compiler where
158− empty = compilerThrow "Hakyll.Core.Compiler.Internal: empty alternative"
159− x <|> y = compilerCatch x (\_ -> y)
160+ empty = compilerThrow []
161+ x <|> y = compilerCatch x $ \es -> do
162+ logger <- compilerLogger <$> compilerAsk
163+ forM_ es $ \e -> compilerUnsafeIO $ Logger.debug logger $
164+ "Hakyll.Core.Compiler.Internal: Alternative failed: " ++ e
165+ y
160166 {-# INLINE (<|>) #-}
161167
162168
@@ -173,13 +179,13 @@ compilerTell deps = Compiler $ \_ -> return $ CompilerDone () deps
173179
174180
175181--------------------------------------------------------------------------------
176−compilerThrow :: String -> Compiler a
177−compilerThrow e = Compiler $ \_ -> return $ CompilerError e
182+compilerThrow :: [String] -> Compiler a
183+compilerThrow es = Compiler $ \_ -> return $ CompilerError es
178184{-# INLINE compilerThrow #-}
179185
180186
181187--------------------------------------------------------------------------------
182−compilerCatch :: Compiler a -> (String -> Compiler a) -> Compiler a
188+compilerCatch :: Compiler a -> ([String] -> Compiler a) -> Compiler a
183189compilerCatch (Compiler x) f = Compiler $ \r -> do
184190 res <- x r
185191 case res of