summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-15 13:02:13 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-17 21:28:52 +0800
commitf1a169bee9fd1f5a8995db0d588680d96d647937 (patch)
tree3596590a167bc41804a147b8a5229ef15ca158c0
parent4990c65d254cec6328136af4bd2d05b766b4016e (diff)
chore(client::new): propagate error
-rw-r--r--src/client/client.rs7
-rw-r--r--src/client/main.rs2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/client/client.rs b/src/client/client.rs
index 617b688..37128b3 100644
--- a/src/client/client.rs
+++ b/src/client/client.rs
@@ -51,7 +51,7 @@ impl<C: Connection> std::fmt::Display for Client<C> {
}
impl<C: Connection> Client<C> {
- pub fn new(connector: C) -> Self {
+ pub fn new(connector: C) -> Result<Self, C::Err> {
let c = Self {
ip: connector.get_ip(),
connector,
@@ -69,9 +69,8 @@ impl<C: Connection> Client<C> {
},
env: std::env::vars().collect(),
};
- // FIXME: handle this and all unwraps
- c.connector.init(&c).unwrap();
- c
+ c.connector.init(&c)?;
+ Ok(c)
}
pub fn enter_loop(mut self) -> ! {
diff --git a/src/client/main.rs b/src/client/main.rs
index 24c8a8b..fa2017d 100644
--- a/src/client/main.rs
+++ b/src/client/main.rs
@@ -38,6 +38,6 @@ fn main() {
]); // discard err
let ip = "http://127.0.0.1:8080";
- let client = Client::new(HTTPConnector::new(ip, ip, "/").unwrap());
+ let client = Client::new(HTTPConnector::new(ip, ip, "/").unwrap()).unwrap();
client.enter_loop();
}