From d56179dc235874a49ab8ce0be79b59db4e9e84b3 Mon Sep 17 00:00:00 2001 From: Allan Clements Date: Mon, 7 Oct 2024 20:40:09 -0500 Subject: [PATCH] Corrected non-async tungstenite Error to using #[from] --- gremlin-client/src/connection.rs | 3 +-- gremlin-client/src/error.rs | 16 +--------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/gremlin-client/src/connection.rs b/gremlin-client/src/connection.rs index 7b31462a..186d06ca 100644 --- a/gremlin-client/src/connection.rs +++ b/gremlin-client/src/connection.rs @@ -63,12 +63,11 @@ impl ConnectionStream { fn send(&mut self, payload: Vec) -> GremlinResult<()> { self.0 .write_message(Message::Binary(payload)) - .map_err(|e| Arc::new(e)) .map_err(GremlinError::from) } fn recv(&mut self) -> GremlinResult> { - match self.0.read_message().map_err(|e| Arc::new(e))? { + match self.0.read_message()? { Message::Binary(binary) => Ok(binary), _ => unimplemented!(), } diff --git a/gremlin-client/src/error.rs b/gremlin-client/src/error.rs index 58e01214..c88be829 100644 --- a/gremlin-client/src/error.rs +++ b/gremlin-client/src/error.rs @@ -14,7 +14,7 @@ pub enum GremlinError { Generic(String), #[error(transparent)] - WebSocket(tungstenite::error::Error), + WebSocket(#[from] tungstenite::Error), #[error(transparent)] Pool(#[from] r2d2::Error), @@ -56,17 +56,3 @@ impl From> for GremlinError { } } } - -#[cfg(not(feature = "async_gremlin"))] -impl From for GremlinError { - fn from(e: tungstenite::error::Error) -> GremlinError { - let error = match e { - tungstenite::error::Error::AlreadyClosed => tungstenite::error::Error::AlreadyClosed, - tungstenite::error::Error::ConnectionClosed => { - tungstenite::error::Error::ConnectionClosed - } - _ => return GremlinError::Generic(format!("Error from ws {}", e)), - }; - GremlinError::WebSocket(error) - } -}