From 93d9a3b8d6984a8f113a30fea523607162e71589 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Fri, 9 Apr 2021 20:26:19 -0400 Subject: better startup configuration --- src/error.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 06d7d1e..943c3ec 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,25 +1,26 @@ use bincode::Error as bincode_e; use sled::Error as sled_e; +use std::fmt; #[derive(Debug)] -pub struct TwinHError; +pub struct TwinHError(pub String); impl std::error::Error for TwinHError {} impl std::fmt::Display for TwinHError { - fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { - todo!() + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { + write!(f, "Twin H-Power: {}", self.0) } } impl From for TwinHError { - fn from(_: sled_e) -> Self { - todo!() + fn from(e: sled_e) -> Self { + Self(format!("database error: {}", e)) } } impl From for TwinHError { - fn from(_: bincode_e) -> Self { - todo!() + fn from(e: bincode_e) -> Self { + Self(format!("(de)serialization error: {}", e)) } } -- cgit v1.2.3