net: more useful debug logs

This commit is contained in:
dr-frmr 2024-06-04 18:14:36 -06:00
parent 9db2ad638d
commit b4e9ffa145
No known key found for this signature in database
3 changed files with 25 additions and 3 deletions

View File

@ -100,7 +100,18 @@ pub async fn init_direct(
));
Ok(())
}
_ => return Err(peer_rx),
Ok(Err(e)) => {
print_debug(
&ext.print_tx,
&format!("net: error in tcp::init_direct: {e}"),
)
.await;
return Err(peer_rx);
}
Err(_) => {
print_debug(&ext.print_tx, "net: tcp::init_direct timed out").await;
return Err(peer_rx);
}
}
}

View File

@ -113,7 +113,18 @@ pub async fn init_direct(
));
Ok(())
}
_ => return Err(peer_rx),
Ok(Err(e)) => {
print_debug(
&ext.print_tx,
&format!("net: error in ws::init_direct: {e}"),
)
.await;
return Err(peer_rx);
}
Err(_) => {
print_debug(&ext.print_tx, "net: ws::init_direct timed out").await;
return Err(peer_rx);
}
}
}

View File

@ -211,7 +211,7 @@ pub async fn recv(socket: &mut WebSocket) -> anyhow::Result<Vec<u8>> {
}
Some(Ok(tungstenite::Message::Pong(_))) => continue,
Some(Ok(tungstenite::Message::Binary(bin))) => return Ok(bin),
_ => return Err(anyhow::anyhow!("websocket closed")),
_ => return Err(anyhow::anyhow!("invalid websocket message received")),
}
}
}