Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where do error messages go? #82

Closed
ghenry opened this issue Aug 12, 2024 · 2 comments
Closed

Where do error messages go? #82

ghenry opened this issue Aug 12, 2024 · 2 comments

Comments

@ghenry
Copy link

ghenry commented Aug 12, 2024

Hi all,

I'm using the following example:

"no private key found".to_string(),

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
Copy link
Member

ctz commented Aug 12, 2024

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
Copy link
Author

ghenry commented Aug 12, 2024

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.

@ctz ctz closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants