@@ -6,13 +6,14 @@ module Text.Hakyll.Internal.Template.Hamlet
6 , fromHamletRT
6 , fromHamletRT
9+import Control.Exception (try)
9import Control.Monad.Trans (liftIO)
10import Control.Monad.Trans (liftIO)
10import System.FilePath (takeExtension)
11import System.FilePath (takeExtension)
12import Text.Hamlet.RT
13import Text.Hamlet.RT
14import Text.Hakyll.Internal.Template.Template
15import Text.Hakyll.Internal.Template.Template
15−import Text.Hakyll.HakyllMonad (Hakyll, askHakyll, hamletSettings)
16+import Text.Hakyll.HakyllMonad (Hakyll, askHakyll, hamletSettings, logHakyll)
17-- | Determine if a file is a hamlet template by extension.
18-- | Determine if a file is a hamlet template by extension.
@@ -26,7 +27,17 @@ readHamletRT :: FilePath -- ^ Filename of the template
26readHamletRT fileName = do
27readHamletRT fileName = do
27 settings <- askHakyll hamletSettings
28 settings <- askHakyll hamletSettings
28 string <- liftIO $ readFile fileName
29 string <- liftIO $ readFile fileName
29− liftIO $ parseHamletRT settings string
30+ result <- liftIO $ try $ parseHamletRT settings string
32+ Left (HamletParseException s) -> error' s
33+ Left (HamletUnsupportedDocException d) -> error' $ show d
34+ Left (HamletRenderException s) -> error' s
38+ logHakyll $ "Parse of hamlet file " ++ fileName ++ " failed."
40+ error "Parse failed."
31-- | Convert a 'HamletRT' to a 'Template'
42-- | Convert a 'HamletRT' to a 'Template'