diff --git a/libsignal-service-actix/src/websocket.rs b/libsignal-service-actix/src/websocket.rs index 5de4cbee3..5f62298fd 100644 --- a/libsignal-service-actix/src/websocket.rs +++ b/libsignal-service-actix/src/websocket.rs @@ -22,6 +22,8 @@ pub struct AwcWebSocket { pub enum AwcWebSocketError { #[error("Could not connect to the Signal Server")] ConnectionError(#[from] awc::error::WsClientError), + #[error("Error during Websocket connection")] + ProtocolError(#[from] WsProtocolError), } impl From for ServiceError { @@ -38,19 +40,31 @@ impl From for ServiceError { reason: e.to_string(), }, }, + AwcWebSocketError::ProtocolError(e) => match e { + WsProtocolError::Io(e) => match e.kind() { + std::io::ErrorKind::UnexpectedEof => { + ServiceError::WsClosing { + reason: format!( + "WebSocket closing due to unexpected EOF: {}", + e + ), + } + }, + _ => ServiceError::WsError { + reason: format!( + "IO error during WebSocket connection: {}", + e + ), + }, + }, + e => ServiceError::WsError { + reason: e.to_string(), + }, + }, } } } -impl From for AwcWebSocketError { - fn from(e: WsProtocolError) -> AwcWebSocketError { - todo!("error conversion {:?}", e) - // return Some(Err(ServiceError::WsError { - // reason: e.to_string(), - // })); - } -} - /// Process the WebSocket, until it times out. async fn process( socket_stream: S,