From 278e763b1bae26975d89cc558f441436d4d3d5c7 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Wed, 14 Jun 2023 22:11:31 +0200 Subject: [PATCH] Report error rather than panicking with `unreachable!` --- src/error.rs | 5 +++++ src/ws_meta.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index d018b1e..1b6c925 100644 --- a/src/error.rs +++ b/src/error.rs @@ -103,6 +103,11 @@ pub enum WsErr #[ error( "Received a message that is neither ArrayBuffer, String or Blob." ) ] // UnknownDataType, + + /// Fallback whenever explicit variant hadling hansn't yet been implemented. + #[error("`{0}`")] + // + Other(String), } diff --git a/src/ws_meta.rs b/src/ws_meta.rs index 1b599ac..101874f 100644 --- a/src/ws_meta.rs +++ b/src/ws_meta.rs @@ -83,7 +83,7 @@ impl WsMeta return Err( WsErr::InvalidUrl{ supplied: url.as_ref().to_string() } ), - _ => unreachable!(), + _ => return Err(WsErr::Other(de.message())), }; } };