rustls / tokio-rustls

Async TLS for the Tokio runtime
Apache License 2.0
125 stars 70 forks source link

Where do error messages go? #82

Closed ghenry closed 3 months ago

ghenry commented 3 months ago

Hi all,

I'm using the following example:

https://github.com/rustls/tokio-rustls/blob/6f7373dad47df0b071c8f0f1a03376bed08331e7/examples/server.rs#L43

when the private key doesn't exist, how do you get that panic error message?

I'm using the example here https://github.com/SentryPeer/SentryPeer/blob/main/sentrypeer_rust/src/tls.rs#L180

and my cargo test -- --nocapture never shows it or with RUST_BACKTRACE=1:

assertion failed: result.is_ok()
stack backtrace:
   0: rust_begin_unwind
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/panicking.rs:146:5
   3: sentrypeer_rust::tls::tests::test_listen
             at ./src/tls.rs:194:13
   4: sentrypeer_rust::tls::tests::test_listen::{{closure}}
             at ./src/tls.rs:180:21
   5: core::ops::function::FnOnce::call_once
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ops/function.rs:250:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test tls::tests::test_listen ... FAILED

this is probably my beginner mistake or misunderstanding or Tokio.

Any doc pointers you can share with me?

Thanks.

ctz commented 3 months ago

assert!(result.is_ok()); takes a Result and turns it into a bool by discarding all the error/success data it contained, then asserts that is true. This means the assert has no information about why. How about just result.unwrap();?

ghenry commented 3 months ago

Thanks. I didn't even think as basic as that. Much appreciated. Switching to result.unwrap(); instead of using an assert, I get:

called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

which is better...so definitely my beginner mistake. Feeling dumb now.