include source in error
This commit is contained in:
parent
e2c74b8dfe
commit
ededfd9e55
@ -8,7 +8,10 @@ pub struct Runner{
|
|||||||
}
|
}
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
Lua(mlua::Error),
|
Lua{
|
||||||
|
source:String,
|
||||||
|
error:mlua::Error
|
||||||
|
},
|
||||||
Script(crate::script::Error),
|
Script(crate::script::Error),
|
||||||
/// If the lua.remove_app_data function fails
|
/// If the lua.remove_app_data function fails
|
||||||
RemoveAppData,
|
RemoveAppData,
|
||||||
@ -16,8 +19,8 @@ pub enum Error{
|
|||||||
impl Error{
|
impl Error{
|
||||||
pub fn print(self){
|
pub fn print(self){
|
||||||
match self{
|
match self{
|
||||||
Self::Lua(mlua::Error::RuntimeError(s))=>{
|
Self::Lua{source,error:mlua::Error::RuntimeError(s)}=>{
|
||||||
println!("lua error: {s}");
|
println!("lua error: {s}\nsource:{source}");
|
||||||
},
|
},
|
||||||
other=>println!("{:?}",other),
|
other=>println!("{:?}",other),
|
||||||
}
|
}
|
||||||
@ -81,11 +84,12 @@ impl Runner{
|
|||||||
//this makes set_app_data shut up about the lifetime
|
//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)});
|
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)?;
|
let (name,source)=yoink.map_err(Error::Script)?;
|
||||||
self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(Error::Lua)?;
|
self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(|error|Error::Lua{source:source.clone(),error})?;
|
||||||
self.lua.load(source)
|
let r=self.lua.load(source.as_str())
|
||||||
.set_name(name)
|
.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>();
|
self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>();
|
||||||
|
r?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user