manen

Fancy Lua REPL
Log | Files | Refs | README | LICENSE

commit 759525159ae3e79db23d64b9e7c2540a0734135c
parent aee2bf99f49e02cfc21ca6a421989826e8e807d8
Author: Sylvia Ivory <git@sivory.net>
Date:   Mon, 30 Jun 2025 17:38:12 -0700

Ensure errors are printed

Diffstat:
Msrc/lua.rs | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lua.rs b/src/lua.rs @@ -70,9 +70,11 @@ pub enum SystemLuaError { Expect(#[from] rexpect::error::Error), #[error("restarted system Lua")] Restarted, + #[error("runtime error")] + RuntimeError(String), } -pub enum RpcCommand { +enum RpcCommand { Globals, Exec(String), } @@ -125,6 +127,10 @@ impl SystemLuaExecutor { }; if let Ok(res) = self.lua.load(&code).eval::<LuaTable>() { + if res.get::<String>("ty")? == "error" { + return Err(SystemLuaError::RuntimeError(res.get("data")?)); + }; + return Ok(res); } else { println!("{}", &code);