Skip to content

Commit d247c47

Browse files
authored
Don't unwrap stream.peer_addr()
postgresml#562 (same code) (another lines changed)
1 parent 7994a66 commit d247c47

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/client.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,15 @@ pub async fn client_entrypoint(
117117
log_client_connections: bool,
118118
) -> Result<(), Error> {
119119
// Figure out if the client wants TLS or not.
120-
let addr = stream.peer_addr().unwrap();
120+
let addr = match stream.peer_addr() {
121+
Ok(addr) => addr,
122+
Err(err) => {
123+
return Err(Error::SocketError(format!(
124+
"Failed to get peer address: {:?}",
125+
err
126+
)));
127+
}
128+
};
121129

122130
match get_startup::<TcpStream>(&mut stream).await {
123131
// Client requested a TLS connection.

0 commit comments

Comments
 (0)