From 957199557bb69d528c9702374828ba8fd246b4aa Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Mon, 27 Jul 2020 22:13:39 -0400 Subject: [PATCH] main: use Result<()> from anyhow to make error handling easier here As the program grows some configuration, it makes sense to let errors propagate gracefully. --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8f9f258..a3abf9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,11 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "anyhow" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" + [[package]] name = "argv" version = "0.1.2" @@ -55,6 +61,7 @@ dependencies = [ name = "durnitisp" version = "0.1.0" dependencies = [ + "anyhow", "gflags", "nursery", "prometheus", diff --git a/Cargo.toml b/Cargo.toml index 66c88c2..2ee0313 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1" gflags = "^0.3" nursery = "^0.0.1" prometheus = "^0.9.0" diff --git a/src/main.rs b/src/main.rs index 5cd0200..481071a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,7 +97,7 @@ fn attempt_stun_connect(addr: SocketAddr) -> Result { Ok(SystemTime::now()) } -fn main() { +fn main() -> anyhow::Result<()> { let default_stun_servers: Vec<&'static str> = vec![ "stun.l.google.com:19302", "stun.ekiga.net:3478", @@ -217,4 +217,5 @@ fn main() { parent.schedule(Box::new(render_thread)); // Blocks forever parent.wait(); + Ok(()) }