From 42ae6b73404ea29fdc6aa2b1caacb40e04c3df9d Mon Sep 17 00:00:00 2001 From: Nathan KREMER Date: Sun, 15 Oct 2023 18:20:29 +0200 Subject: [PATCH] fix from tungstenite error --- gremlin-client/src/error.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gremlin-client/src/error.rs b/gremlin-client/src/error.rs index f762847e..068676d6 100644 --- a/gremlin-client/src/error.rs +++ b/gremlin-client/src/error.rs @@ -54,3 +54,17 @@ 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) + } +}