Commits

Anonymous committed 1a647aa

lua.highlevel: use typeError where appropriate.

Comments (0)

Files changed (1)

lib-clay/lua/highlevel/highlevel.clay

     var size = SizeT();
     var ptr = lua_tolstring(x.handle, index, &size);
     if (null?(ptr))
-        throw Error("not a string");
+        typeError(x, index, "string");
     var ptr2 = Pointer[Char](ptr);
     // HACK: assumes that (ptr2 + size)^ is byte value 0.
     return StringConstant(ptr2, ptr2 + size);
 toUserData(x:State, index:Int) {
     var ptr = lua_touserdata(x.handle, index);
     if (null?(ptr))
-        throw Error("not a userdatum");
+        typeError(x, index, "userdata");
     return ptr;
 }
 
 toCFunction(x:State, index:Int) {
     var ptr = lua_tocfunction(x.handle, index);
     if (null?(ptr))
-        throw Error("not a c-function");
+        typeError(x, index, "cfunction");
     return ptr;
 }