Skip to content

Commit

Permalink
work around a crash when returning an error to Lua
Browse files Browse the repository at this point in the history
Refs #19
  • Loading branch information
rkusa committed Aug 21, 2021
1 parent 4e6e472 commit bd54607
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,16 @@ fn next(lua: &Lua, callback: Function) -> LuaResult<bool> {
}

fn event(lua: &Lua, event: Value) -> LuaResult<()> {
let event: Event = lua
.from_value(event)
.map_err(|err| mlua::Error::ExternalError(Arc::new(Error::DeserializeParams(err))))?;
let event: Event = match lua.from_value(event) {
Ok(event) => event,
Err(err) => {
log::error!("failed to deserialize event: {}", err);
// In certain cases DCS crashes when we return an error back to Lua here (see
// https://github.com/DCS-gRPC/rust-server/issues/19), which we are working around
// by intercepting and logging the error instead.
return Ok(());
}
};

if let Some(Server {
ref ipc,
Expand Down

0 comments on commit bd54607

Please sign in to comment.