From c6f2d303e227e43e9d66102c9c066f6c8a67bf2d Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sun, 28 Jan 2024 11:27:52 -0500 Subject: [PATCH] Improve error message for meta methods on userdata --- src/userdata.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/userdata.rs b/src/userdata.rs index 906a2cf..086d16d 100755 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -218,12 +218,17 @@ impl<'a, T: Userdata> UserdataBuilder<'a, T> { R: AsLua<'a>, T: Userdata + 'static { + let fn_name = name.as_ref().to_string(); let wrap = move |lua: &'a State, mut val: ValueVec<'a>| { let this_val = val.pop_front().unwrap(); let this = this_val.as_userdata().unwrap(); // if this panics, its a bug let this = this.as_ref::()?; - 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)) };