mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Improved error messages when a function which expects a love type gets something else
This commit is contained in:
@@ -363,12 +363,12 @@ template <typename T>
|
|||||||
T *luax_checktype(lua_State *L, int idx, const char *name, love::bits type)
|
T *luax_checktype(lua_State *L, int idx, const char *name, love::bits type)
|
||||||
{
|
{
|
||||||
if (lua_isuserdata(L, idx) == 0)
|
if (lua_isuserdata(L, idx) == 0)
|
||||||
luaL_error(L, "Incorrect parameter type: expected userdata.");
|
luax_typerror(L, idx, name);
|
||||||
|
|
||||||
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
Proxy *u = (Proxy *)lua_touserdata(L, idx);
|
||||||
|
|
||||||
if ((u->flags & type) != type)
|
if ((u->flags & type) != type)
|
||||||
luaL_error(L, "Incorrect parameter type: expected %s", name);
|
luax_typerror(L, idx, name);
|
||||||
|
|
||||||
return (T *)u->data;
|
return (T *)u->data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user