Impl display & debug for ServerError

This commit is contained in:
NGnius (Graham) 2022-06-13 20:17:20 -04:00
parent 03d7ac54d1
commit 4a537f4d42
3 changed files with 12 additions and 2 deletions

2
Cargo.lock generated
View file

@ -411,7 +411,7 @@ dependencies = [
[[package]]
name = "usdpl-back"
version = "0.1.0"
version = "0.2.1"
dependencies = [
"tungstenite",
"usdpl-core",

View file

@ -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"

View file

@ -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>;