first-rust-competition / nt-rs

Rust implementation of NetworkTables (v3)
MIT License
8 stars 6 forks source link

NetworkTables::connect() panic. #9

Closed RyanHir closed 3 years ago

RyanHir commented 3 years ago

Hello,

The example read.rs is currently panicking. This is happening when there is not a server to connect to. Instead of panicking, it should return the error to be handled by the user.

To reproduce, run cargo run --example=read without a server process running. You will get the following,,,

thread '<unnamed>' panicked at 'Listing entries
called `Result::unwrap()` on an `Err` value: IO(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })', /home/ryan/devel/nt-rs/src/proto/client.rs:57:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

With RUST_BACKTRACE=1 enabled, you should get...

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: IO(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })', /home/ryan/devel/nt-rs/src/proto/client.rsListing entries
:57:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
   3: core::result::Result<T,E>::unwrap
             at /home/ryan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
   4: nt::proto::client::ClientState::new::{{closure}}::{{closure}}
             at ./src/proto/client.rs:56:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.