diff options
author | Liran Ringel <5730310+liranringel@users.noreply.github.com> | 2018-11-20 18:10:36 +0200 |
---|---|---|
committer | Toby Lawrence <tobz@users.noreply.github.com> | 2018-11-20 11:10:36 -0500 |
commit | 9b1a45cc6a15f5d2be17531dffc2f50d2b019646 (patch) | |
tree | da66c5c9574f2cd7ad11745e414fc34da2e35c6f /examples/tinydb.rs | |
parent | 477fa5580aa3796f97e3e0eb1325d4690b3b4e96 (diff) |
tests: handle errors properly in examples (#748)
Diffstat (limited to 'examples/tinydb.rs')
-rw-r--r-- | examples/tinydb.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/tinydb.rs b/examples/tinydb.rs index 134d01b1..702704d3 100644 --- a/examples/tinydb.rs +++ b/examples/tinydb.rs @@ -74,12 +74,12 @@ enum Response { Error { msg: String }, } -fn main() { +fn main() -> Result<(), Box<std::error::Error>> { // Parse the address we're going to run this server on // and set up our TCP listener to accept connections. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); - let addr = addr.parse::<SocketAddr>().unwrap(); - let listener = TcpListener::bind(&addr).expect("failed to bind"); + let addr = addr.parse::<SocketAddr>()?; + let listener = TcpListener::bind(&addr).map_err(|_| "failed to bind")?; println!("Listening on: {}", addr); // Create the shared state of this server that will be shared amongst all @@ -156,6 +156,7 @@ fn main() { }); tokio::run(done); + Ok(()) } impl Request { |