From 4a537f4d420347983638d037777f7dee9754a86a Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 13 Jun 2022 20:17:20 -0400 Subject: [PATCH] Impl display & debug for ServerError --- Cargo.lock | 2 +- usdpl-back/Cargo.toml | 2 +- usdpl-back/src/errors.rs | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcbd3f6..bc6bdf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,7 +411,7 @@ dependencies = [ [[package]] name = "usdpl-back" -version = "0.1.0" +version = "0.2.1" dependencies = [ "tungstenite", "usdpl-core", diff --git a/usdpl-back/Cargo.toml b/usdpl-back/Cargo.toml index 9080157..4f077f7 100644 --- a/usdpl-back/Cargo.toml +++ b/usdpl-back/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "usdpl-back" -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "GPL-3.0-only" repository = "https://github.com/NGnius/usdpl-rs" diff --git a/usdpl-back/src/errors.rs b/usdpl-back/src/errors.rs index 96fbded..38906fd 100644 --- a/usdpl-back/src/errors.rs +++ b/usdpl-back/src/errors.rs @@ -1,6 +1,16 @@ +#[derive(Debug)] pub enum ServerError { Tungstenite(tungstenite::error::Error), Io(std::io::Error), } +impl std::fmt::Display for ServerError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Tungstenite(t) => (&t as &dyn std::fmt::Display).fmt(f), + Self::Io(io) => (&io as &dyn std::fmt::Display).fmt(f), + } + } +} + pub type ServerResult = Result<(), ServerError>;