Browse files

More strict about parse failure

  • Loading branch information...
1 parent 0c05f43 commit 414dbd4cbe8ccade0d69ecf6e1186b2f8f48eb91 @singpolyma committed Nov 26, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 mustache2hs.hs
View
11 mustache2hs.hs
@@ -320,10 +320,13 @@ codeGenFile recs (input, rname) = do
| otherwise -> fail ("Type mismatch, template " ++ input ++ " expects both " ++ r ++ " and " ++ "rname")
Nothing -> do
modify ((input',rname):)
- Right tree <- lift $ parse parser input <$> T.readFile input
- let fname = camelCasePath (dropExtension input)
- let (builder, partials) = evalState (codeGenTree input fname rname recs tree 0) (0::Int)
- return (Just builder, partials)
+ parsed <- lift $ parse (parser <* eof) input <$> T.readFile input
+ case parsed of
+ Right tree -> do
+ let fname = camelCasePath (dropExtension input)
+ let (builder, partials) = evalState (codeGenTree input fname rname recs tree 0) (0::Int)
+ return (Just builder, partials)
+ Left msg -> error (show msg)
where
input' = normalise input

0 comments on commit 414dbd4

Please sign in to comment.