From f1a169bee9fd1f5a8995db0d588680d96d647937 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 15 Sep 2025 13:02:13 +0800 Subject: chore(client::new): propagate error --- src/client/client.rs | 7 +++---- src/client/main.rs | 2 +- 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 std::fmt::Display for Client { } impl Client { - pub fn new(connector: C) -> Self { + pub fn new(connector: C) -> Result { let c = Self { ip: connector.get_ip(), connector, @@ -69,9 +69,8 @@ impl Client { }, 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(); } -- cgit v1.2.3