Unexepcetd eof are treated as backgound errors (almost unimportant)
This commit is contained in:
@@ -65,6 +65,12 @@ impl TerminalServer {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Err(err) = s.handle_client(&id, reader).await {
|
if let Err(err) = s.handle_client(&id, reader).await {
|
||||||
if matches!(err.kind(), tokio::io::ErrorKind::UnexpectedEof) {
|
if matches!(err.kind(), tokio::io::ErrorKind::UnexpectedEof) {
|
||||||
|
Self::print_log(&EventLog {
|
||||||
|
kind: LogKind::Err,
|
||||||
|
name: "engine::terminal".to_string(),
|
||||||
|
message: format!("Terminal connection error: {err}"),
|
||||||
|
});
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +163,7 @@ impl TerminalServer {
|
|||||||
if let Err(e) = Self::send_to_client(client, &msg).await {
|
if let Err(e) = Self::send_to_client(client, &msg).await {
|
||||||
remove_clients.push(*id);
|
remove_clients.push(*id);
|
||||||
|
|
||||||
self.print_log(&EventLog {
|
Self::print_log(&EventLog {
|
||||||
kind: LogKind::Err,
|
kind: LogKind::Err,
|
||||||
name: "engine::terminal".to_string(),
|
name: "engine::terminal".to_string(),
|
||||||
message: format!("Failed to broadcast to client: {e}"),
|
message: format!("Failed to broadcast to client: {e}"),
|
||||||
@@ -286,7 +292,7 @@ impl TerminalServer {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_log(self: &Arc<Self>, log: &EventLog) {
|
pub fn print_log(log: &EventLog) {
|
||||||
println!(
|
println!(
|
||||||
"[{}{}\x1b[0m] (\x1b[37m{}\x1b[0m) {}",
|
"[{}{}\x1b[0m] (\x1b[37m{}\x1b[0m) {}",
|
||||||
match &log.kind {
|
match &log.kind {
|
||||||
@@ -302,7 +308,7 @@ impl TerminalServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn log_raw(self: &Arc<Self>, log: EventLog) -> tokio::io::Result<()> {
|
pub async fn log_raw(self: &Arc<Self>, log: EventLog) -> tokio::io::Result<()> {
|
||||||
self.print_log(&log);
|
Self::print_log(&log);
|
||||||
|
|
||||||
self.logs.lock().await.push(log.clone());
|
self.logs.lock().await.push(log.clone());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user