To understand error handling in std::thread and tokio_threadpool, I modified the example
and make an error happen.
Then I noticed the error message is like below:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libcore/result.rs:1009:5
I think the code position is not helpful since it is the position in the standard library, not my application code.
Then I use map_err
and got improved error messages.
comparison with for witouht map_err
for std::thread
:
comparison with for witouht map_err
for tokio_threadpool
:
Is there a better way to get the correct code position in error messages for code in thread?
My rustc version is:
$ rustup show
Default host: x86_64-unknown-linux-gnu
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.32.0 (9fda7c223 2019-01-16)
Thanks!