diff --git a/src/lib.rs b/src/lib.rs index 2e86af5..2c8a116 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -294,8 +294,8 @@ const ENTITY_VAR_NAME: &str = "entity"; /// An error that can occur when internal [ScriptingPlugin] systems are being executed #[derive(Error, Debug)] pub enum ScriptingError { - #[error("script runtime error: {0}\nscript backtrace:\n{1}")] - RuntimeError(String, String), + #[error("script runtime error: {0}")] + RuntimeError(String), #[error("script compilation error: {0}")] CompileError(Box), #[error("no runtime resource present")] diff --git a/src/runtimes/lua.rs b/src/runtimes/lua.rs index d5ff891..59c1217 100644 --- a/src/runtimes/lua.rs +++ b/src/runtimes/lua.rs @@ -187,7 +187,7 @@ impl Runtime for LuaRuntime { .expect("Error clearing entity global variable"); result }) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; Ok(LuaScriptData) } @@ -236,14 +236,14 @@ impl Runtime for LuaRuntime { let func = engine .globals() .get::<_, Function>(name) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; let args = args .parse(engine) .into_iter() .map(|a| engine.registry_value::(&a.0).unwrap()); let result = func .call::<_, mlua::Value>(Variadic::from_iter(args)) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; engine .globals() .set(ENTITY_VAR_NAME, mlua::Value::Nil) @@ -261,13 +261,13 @@ impl Runtime for LuaRuntime { self.with_engine(|engine| { let val = engine .registry_value::(&value.0) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; let args = args .into_iter() .map(|a| engine.registry_value::(&a.0).unwrap()); let result = val .call::<_, mlua::Value>(Variadic::from_iter(args)) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; Ok(LuaValue::new(engine, result)) }) } diff --git a/src/runtimes/rhai.rs b/src/runtimes/rhai.rs index c927cbb..6718f95 100644 --- a/src/runtimes/rhai.rs +++ b/src/runtimes/rhai.rs @@ -105,7 +105,7 @@ impl Runtime for RhaiRuntime { engine .run_ast_with_scope(&mut scope, &ast) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))?; + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))?; scope.remove::(ENTITY_VAR_NAME).unwrap(); @@ -156,7 +156,7 @@ impl Runtime for RhaiRuntime { scope.remove::(ENTITY_VAR_NAME).unwrap(); match result { Ok(val) => Ok(RhaiValue(val)), - Err(e) => Err(ScriptingError::RuntimeError(e.to_string(), "".to_string())), + Err(e) => Err(ScriptingError::RuntimeError(e.to_string())), } } @@ -173,11 +173,11 @@ impl Runtime for RhaiRuntime { let result = if args.len() == 1 && args.first().unwrap().0.is_unit() { f.call_raw(ctx, None, []) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))? + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))? } else { let args = args.into_iter().map(|a| a.0).collect::>(); f.call_raw(ctx, None, args) - .map_err(|e| ScriptingError::RuntimeError(e.to_string(), "".to_string()))? + .map_err(|e| ScriptingError::RuntimeError(e.to_string()))? }; Ok(RhaiValue(result)) diff --git a/src/runtimes/ruby.rs b/src/runtimes/ruby.rs index 4299a0c..f00103d 100644 --- a/src/runtimes/ruby.rs +++ b/src/runtimes/ruby.rs @@ -222,7 +222,8 @@ impl TryConvert for BevyVec3 { impl From for ScriptingError { fn from(value: magnus::Error) -> Self { - ScriptingError::RuntimeError( + ScriptingError::RuntimeError(format!( + "error: {}\nbacktrace:\n{}\n", value.inspect(), value .value() @@ -232,7 +233,7 @@ impl From for ScriptingError { .to_vec::() .expect("Failed to convert backtrace to vec of strings") .join("\n"), - ) + )) } }