Error message does not need thread id

This commit is contained in:
Filip Tibell 2024-01-17 13:42:46 +01:00
parent c920d31126
commit a4599618de
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View file

@ -103,8 +103,7 @@ fn main_lua_task(mut rx: MessageReceiver, tx: MessageSender, stats: Stats) -> Lu
}
};
if let Err(e) = thread.resume::<_, ()>(args) {
tx.send(Message::Error(thread_id, Box::new(e)))
.expect("failed to send error to async task");
tx.send(Message::WriteError(e)).unwrap();
} else if thread.status() == LuaThreadStatus::Resumable {
yielded_threads.insert(thread_id, thread);
}
@ -165,7 +164,7 @@ async fn main_async_task(
let process_message = |message| {
match message {
Message::Sleep(_, _, _) => stats.incr(StatsCounter::ThreadSlept),
Message::Error(_, _) => stats.incr(StatsCounter::ThreadErrored),
Message::WriteError(_) => stats.incr(StatsCounter::ThreadErrored),
Message::WriteStdout(_) => stats.incr(StatsCounter::WriteStdout),
Message::WriteStderr(_) => stats.incr(StatsCounter::WriteStderr),
_ => unreachable!(),
@ -180,7 +179,7 @@ async fn main_async_task(
tx.send(Message::Resume(thread_id, Ok(AsyncValues::from(elapsed))))
});
}
Message::Error(_, e) => {
Message::WriteError(e) => {
forward_stderr(b"Lua error: ".to_vec());
forward_stderr(e.to_string().as_bytes().to_vec());
}

View file

@ -15,7 +15,7 @@ pub enum Message {
Resume(ThreadId, LuaResult<AsyncValues>),
Cancel(ThreadId),
Sleep(ThreadId, Instant, Duration),
Error(ThreadId, Box<LuaError>),
WriteError(LuaError),
WriteStdout(Vec<u8>),
WriteStderr(Vec<u8>),
}