diff --git a/src/runner/runner.rs b/src/runner/runner.rs index fc0fbb6..8475486 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -8,7 +8,10 @@ pub struct Runner{ } #[derive(Debug)] pub enum Error{ - Lua(mlua::Error), + Lua{ + source:String, + error:mlua::Error + }, Script(crate::script::Error), /// If the lua.remove_app_data function fails RemoveAppData, @@ -16,8 +19,8 @@ pub enum Error{ impl Error{ pub fn print(self){ match self{ - Self::Lua(mlua::Error::RuntimeError(s))=>{ - println!("lua error: {s}"); + Self::Lua{source,error:mlua::Error::RuntimeError(s)}=>{ + println!("lua error: {s}\nsource:{source}"); }, other=>println!("{:?}",other), } @@ -81,11 +84,12 @@ impl Runner{ //this makes set_app_data shut up about the lifetime self.lua.set_app_data::<&'static mut rbx_dom_weak::WeakDom>(unsafe{core::mem::transmute(&mut context.dom)}); let (name,source)=yoink.map_err(Error::Script)?; - self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(Error::Lua)?; - self.lua.load(source) + self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(|error|Error::Lua{source:source.clone(),error})?; + let r=self.lua.load(source.as_str()) .set_name(name) - .exec().map_err(Error::Lua)?; + .exec().map_err(|error|Error::Lua{source,error}); self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>(); + r?; Ok(()) } }