Improve error message for meta methods on userdata
This commit is contained in:
parent
716b54797d
commit
c6f2d303e2
|
@ -218,12 +218,17 @@ impl<'a, T: Userdata> UserdataBuilder<'a, T> {
|
||||||
R: AsLua<'a>,
|
R: AsLua<'a>,
|
||||||
T: Userdata + 'static
|
T: Userdata + 'static
|
||||||
{
|
{
|
||||||
|
let fn_name = name.as_ref().to_string();
|
||||||
let wrap = move |lua: &'a State, mut val: ValueVec<'a>| {
|
let wrap = move |lua: &'a State, mut val: ValueVec<'a>| {
|
||||||
let this_val = val.pop_front().unwrap();
|
let this_val = val.pop_front().unwrap();
|
||||||
let this = this_val.as_userdata().unwrap(); // if this panics, its a bug
|
let this = this_val.as_userdata().unwrap(); // if this panics, its a bug
|
||||||
let this = this.as_ref::<T>()?;
|
let this = this.as_ref::<T>()?;
|
||||||
|
|
||||||
let args = A::from_lua_value_vec(lua, val)?;
|
let this_name = T::name();
|
||||||
|
let args = Self::result_to_bad_arg(
|
||||||
|
A::from_lua_value_vec(lua, val),
|
||||||
|
&this_name, &fn_name
|
||||||
|
)?;
|
||||||
|
|
||||||
f(lua, this, args).and_then(|r| r.as_lua(lua))
|
f(lua, this, args).and_then(|r| r.as_lua(lua))
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue