mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Add ExpiredUserData error and avoid what was previously a panic
Also make sure that panic messages clearly state that they are internal errors, so people report them as a bug. Since the only panics left are all internal errors, just move the internal error message into the panic / assert macros.
This commit is contained in:
+2
-2
@@ -567,7 +567,7 @@ impl Lua {
|
||||
&LUA_USERDATA_REGISTRY_KEY as *const u8 as *mut c_void,
|
||||
);
|
||||
ffi::lua_gettable(self.state, ffi::LUA_REGISTRYINDEX);
|
||||
let registered_userdata = get_userdata::<HashMap<TypeId, c_int>>(self.state, -1);
|
||||
let registered_userdata = get_userdata::<HashMap<TypeId, c_int>>(self.state, -1)?;
|
||||
ffi::lua_pop(self.state, 1);
|
||||
|
||||
if let Some(table_id) = (*registered_userdata).get(&TypeId::of::<T>()) {
|
||||
@@ -798,7 +798,7 @@ impl Lua {
|
||||
ephemeral: true,
|
||||
};
|
||||
|
||||
let func = get_userdata::<RefCell<Callback>>(state, ffi::lua_upvalueindex(1));
|
||||
let func = get_userdata::<RefCell<Callback>>(state, ffi::lua_upvalueindex(1))?;
|
||||
let mut func = (*func)
|
||||
.try_borrow_mut()
|
||||
.map_err(|_| Error::RecursiveCallbackError)?;
|
||||
|
||||
Reference in New Issue
Block a user