lunar-mining 4 лет назад
Родитель
Сommit
0e20fa2e6d
2 измененных файлов с 3 добавлено и 10 удалено
  1. 1 1
      example/dchat/src/error.rs
  2. 2 9
      example/dchat/src/main.rs

+ 1 - 1
example/dchat/src/error.rs

@@ -8,7 +8,7 @@ pub struct MissingSpecifier;
 
 
 impl fmt::Display for MissingSpecifier {
 impl fmt::Display for MissingSpecifier {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "missing node specifier")
+        write!(f, "missing node specifier. you must specify either a or b")
     }
     }
 }
 }
 
 

+ 2 - 9
example/dchat/src/main.rs

@@ -301,20 +301,13 @@ async fn main() -> Result<()> {
     let file = File::create(log_path).unwrap();
     let file = File::create(log_path).unwrap();
     WriteLogger::init(log_level, log_config, file)?;
     WriteLogger::init(log_level, log_config, file)?;
 
 
-    // TODO:: proper error handling
     let settings: Result<Settings> = match std::env::args().nth(1) {
     let settings: Result<Settings> = match std::env::args().nth(1) {
         Some(id) => match id.as_str() {
         Some(id) => match id.as_str() {
             "a" => alice(),
             "a" => alice(),
             "b" => bob(),
             "b" => bob(),
-            _ => {
-                println!("you must specify either a or b");
-                Err(MissingSpecifier.into())
-            }
+            _ => Err(MissingSpecifier.into()),
         },
         },
-        None => {
-            println!("you must specify either a or b");
-            Err(MissingSpecifier.into())
-        }
+        None => Err(MissingSpecifier.into()),
     };
     };
 
 
     let p2p = net::P2p::new(settings?.into()).await;
     let p2p = net::P2p::new(settings?.into()).await;