manen

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

commit a950776d8eb489cec38c2fc5c0dc2afa12e42ac6
parent 9dcf5c6be4fdcbe633b191dac2de05616b6f24a3
Author: Sylvia Ivory <git@sivory.net>
Date:   Mon, 30 Jun 2025 17:18:35 -0700

Allow system Lua to restart on failure

Diffstat:
Msrc/lua.rs | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/lua.rs b/src/lua.rs @@ -64,10 +64,12 @@ pub struct SystemLuaExecutor { #[derive(Debug, Error)] pub enum SystemLuaError { - #[error("lua error: {0}")] + #[error("lua error: {0}")] Lua(#[from] LuaError), #[error("expect error: {0}")] Expect(#[from] rexpect::error::Error), + #[error("restarted system Lua")] + Restarted, } pub enum RpcCommand { @@ -112,7 +114,14 @@ impl SystemLuaExecutor { let cmd = command.to_lua(); process.send_line(&cmd)?; - let code = process.read_line()?; + let code = match process.read_line() { + Ok(code) => code, + Err(rexpect::error::Error::EOF { .. }) => { + *process = SendWrapper::new(Self::obtain_process(&self.program)?); + return Err(SystemLuaError::Restarted); + } + x => x?, + }; Ok(self.lua.load(code).eval()?) }