summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs15
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))
}
}