diff options
| author | troido <troido@protonmail.com> | 2020-04-06 19:28:45 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-06 19:28:45 +0200 |
| commit | 7c351a0c7a497d30f4826a19e6c6e92d3e7b5065 (patch) | |
| tree | 26add4ae11f03b2435c149ef5fe95d66afd60eda /src/main.rs | |
| parent | 66a3d3131f32e7bae2f0f7c4fd0b0c876eb3e8a0 (diff) | |
improved error handling
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index 8c2c716..b4e8d82 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,12 +62,12 @@ use self::{ -fn main() -> Result<()>{ +fn main(){ let config = config::Config::from_args(); let adresses = config.address - .unwrap_or(vec!["abstract:rustifarm".parse()?, "inet:127.0.0.1:1234".parse()?]); + .unwrap_or(vec!["abstract:rustifarm".parse().unwrap(), "inet:127.0.0.1:1234".parse().unwrap()]); println!("adresses: {:?}", adresses); let servers: Vec<Box<dyn Server>> = adresses @@ -90,10 +90,10 @@ fn main() -> Result<()>{ content_dir .join("encyclopediae") .join("default_encyclopedia.json") - )? - )? - )?; - encyclopedia.validate()?; + ).expect("can not load default_encyclopedia.json") + ).expect("default_encyclopedia is invalid json") + ).expect("can not load encyclopedia from json"); + encyclopedia.validate().expect("invalid encyclopedia"); let save_dir = config.save_dir.unwrap_or( FileStorage::default_save_dir().expect("couldn't find any save directory") @@ -127,10 +127,10 @@ fn main() -> Result<()>{ let _ = world.control_player(player, control); } Action::Join(player) => { - world.add_player(&player)?; + world.add_player(&player).expect("can not add player"); } Action::Leave(player) => { - world.remove_player(&player)?; + world.remove_player(&player).expect("can not remove player"); message_cache.remove(&player); } } @@ -156,7 +156,6 @@ fn main() -> Result<()>{ println!("saving world"); world.save(); println!("world saved"); - Ok(()) } |
