summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2021-04-15 20:03:01 -0400
committerAdam T. Carpenter <atc@53hor.net>2021-04-15 20:03:01 -0400
commitd83fe68ed51016bbb87d83aa512ef8b9d3f0780e (patch)
tree05f93d34464692c706288f7bb3497f55e4539b09 /src/error.rs
parent93d9a3b8d6984a8f113a30fea523607162e71589 (diff)
downloadtwinh-d83fe68ed51016bbb87d83aa512ef8b9d3f0780e.tar.xz
twinh-d83fe68ed51016bbb87d83aa512ef8b9d3f0780e.zip
split config into modules that actually need it, started parsing args
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs
index 943c3ec..ef0ef1d 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,6 +1,9 @@
use bincode::Error as bincode_e;
+use hyper::Error as hyper_e;
use sled::Error as sled_e;
use std::fmt;
+use std::net::AddrParseError;
+use std::num::ParseIntError;
#[derive(Debug)]
pub struct TwinHError(pub String);
@@ -9,7 +12,7 @@ impl std::error::Error for TwinHError {}
impl std::fmt::Display for TwinHError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
- write!(f, "Twin H-Power: {}", self.0)
+ write!(f, "twinh: {}", self.0)
}
}
@@ -24,3 +27,21 @@ impl From<bincode_e> for TwinHError {
Self(format!("(de)serialization error: {}", e))
}
}
+
+impl From<AddrParseError> for TwinHError {
+ fn from(e: AddrParseError) -> Self {
+ Self(format!("failed to parse addr: {}", e))
+ }
+}
+
+impl From<ParseIntError> for TwinHError {
+ fn from(e: ParseIntError) -> Self {
+ Self(format!("failed to parse port: {}", e))
+ }
+}
+
+impl From<hyper_e> for TwinHError {
+ fn from(e: hyper_e) -> Self {
+ Self(format!("server error: {}", e))
+ }
+}