From 02b6cf12a1b48d156daded3ddba372b7484c5dfb Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sun, 19 Oct 2025 03:30:15 +0200 Subject: [PATCH] feat: Improved device conversion error message --- automation_lib/src/device.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/automation_lib/src/device.rs b/automation_lib/src/device.rs index 6adacb5..3c0b82b 100644 --- a/automation_lib/src/device.rs +++ b/automation_lib/src/device.rs @@ -27,7 +27,7 @@ impl mlua::FromLua for Box { fn from_lua(value: mlua::Value, _lua: &mlua::Lua) -> mlua::Result { match value { mlua::Value::UserData(ud) => { - let ud = if ud.is::>() { + let ud = if ud.is::() { ud } else { ud.call_method::<_>("__box", ())? @@ -36,7 +36,10 @@ impl mlua::FromLua for Box { let b = ud.borrow::()?.clone(); Ok(b) } - _ => Err(mlua::Error::RuntimeError("Expected user data".into())), + _ => Err(mlua::Error::runtime(format!( + "Expected user data, instead found: {}", + value.type_name() + ))), } } }