a bit more error-handling
Getty Ritter
1 year, 10 months ago
107 | 107 | _ <- Lua.dostring luaSource |
108 | 108 | telml <- Lua.getglobal "telml" |
109 | 109 | if telml /= Lua.TypeTable |
110 |
then |
|
110 | then throw (RedefinedTable telml) | |
111 | 111 | else return () |
112 | 112 | handleDoc doc |
113 | 113 | |
148 | 148 | ppType (nafActual naf), |
149 | 149 | " instead" |
150 | 150 | ] |
151 | where | |
152 | 151 | |
153 | 152 | data NotAString = NotAString |
154 | 153 | {nasName :: Text.Text, nasActual :: Lua.Type} |
163 | 162 | ppType (nasActual nas), |
164 | 163 | " instead" |
165 | 164 | ] |
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 | ] | |
167 | 177 | |
168 | 178 | ppType :: Lua.Type -> String |
169 | 179 | ppType Lua.TypeNil = "nil" |