diff options
author | Adam T. Carpenter <atc@53hor.net> | 2021-04-09 20:26:19 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2021-04-09 20:26:19 -0400 |
commit | 93d9a3b8d6984a8f113a30fea523607162e71589 (patch) | |
tree | 7856d0a2fd6701ff23a96321f740ccccb15a7f0f /src/error.rs | |
parent | 201a37e8d3d0ef4c59b184c0707ec8ddd301a25a (diff) | |
download | twinh-93d9a3b8d6984a8f113a30fea523607162e71589.tar.xz twinh-93d9a3b8d6984a8f113a30fea523607162e71589.zip |
better startup configuration
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 15 |
1 files changed, 8 insertions, 7 deletions
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<sled_e> for TwinHError { - fn from(_: sled_e) -> Self { - todo!() + fn from(e: sled_e) -> Self { + Self(format!("database error: {}", e)) } } impl From<bincode_e> for TwinHError { - fn from(_: bincode_e) -> Self { - todo!() + fn from(e: bincode_e) -> Self { + Self(format!("(de)serialization error: {}", e)) } } |