Skip to content

Commit

Permalink
Better error messages for unknown combinators
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Jul 20, 2010
1 parent f00b51f commit 0c735aa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Util/BlazeFromHtml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,17 @@ fromHtml variant (Parent tag attrs inner) = case combinatorType variant tag of
LeafCombinator -> [combinator]

-- Unknown tag
UnknownCombinator -> error $ "Unknown tag: " ++ tag
UnknownCombinator -> error $ "Tag " ++ tag ++ " is illegal in "
++ show variant
where
combinator = qualifiedSanitize "H." tag ++ attributes'
attributes' = attrs >>= \(k, v) -> if k `elem` attributes variant
then " ! " ++ qualifiedSanitize "A." k ++ " " ++ show v
else error $ "Unknown attribute: " ++ k
else error $ "Attribute " ++ k ++ " is illegal in " ++ show variant

-- Qualifies a tag with the given qualifier if needed, and sanitizes it.
qualifiedSanitize qualifier tag =
(if isNameClash variant tag then qualifier else "") ++ sanitize tag
qualifiedSanitize qualifier tag' =
(if isNameClash variant tag' then qualifier else "") ++ sanitize tag'

-- Check if we can drop the apply operator ($), for readability reasons.
-- This would change:
Expand Down

0 comments on commit 0c735aa

Please sign in to comment.