gdritter repos telml / ff7b76a
a bit more error-handling Getty Ritter 1 year, 11 months ago
1 changed file(s) with 13 addition(s) and 3 deletion(s). Collapse all Expand all
107107 _ <- Lua.dostring luaSource
108108 telml <- Lua.getglobal "telml"
109109 if telml /= Lua.TypeTable
110 then Lua.liftIO (putStrLn "wrong type")
110 then throw (RedefinedTable telml)
111111 else return ()
112112 handleDoc doc
113113
148148 ppType (nafActual naf),
149149 " instead"
150150 ]
151 where
152151
153152 data NotAString = NotAString
154153 {nasName :: Text.Text, nasActual :: Lua.Type}
163162 ppType (nasActual nas),
164163 " instead"
165164 ]
166 where
165
166 data RedefinedTable = RedefinedTable
167 {rtType :: Lua.Type}
168 deriving (Show)
169
170 instance Exn.Exception RedefinedTable where
171 displayException rt =
172 concat
173 [ "Configuration file redefined `telml` to non-table; found ",
174 ppType (rtType rt),
175 " instead"
176 ]
167177
168178 ppType :: Lua.Type -> String
169179 ppType Lua.TypeNil = "nil"