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.
This commit is contained in:
Augie Fackler 2020-07-27 22:13:39 -04:00
parent b2d43c1db5
commit 957199557b
3 changed files with 10 additions and 1 deletions

7
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -97,7 +97,7 @@ fn attempt_stun_connect(addr: SocketAddr) -> Result<SystemTime, ConnectError> {
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(())
}