tree-wide: continue unwinds on join failures
The error from joining a thread is a bit confusing. It is only printed
if the other thread panicked. This means, effectively, we only get here
if something called .unwrap(), .expect() or panicked in a different way.
In these cases an (ugly) error was already printend. Printing a pretty
message about the join failure does not really help a lot...
So let's just continue the unwind as suggested by the docs on the join
`Result` [1].
Before:
thread '<unnamed>' panicked at 'Test panic', crates/gpio/src/backend.rs:146:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', crates/gpio/src/backend.rs:176:23
After:
thread '<unnamed>' panicked at 'Test panic', crates/gpio/src/backend.rs:146:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1]: https://doc.rust-lang.org/std/thread/type.Result.html
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
This commit is contained in:
parent
25c6ac3362
commit
2143bcb44c
4 changed files with 9 additions and 10 deletions
|
|
@ -39,8 +39,6 @@ pub(crate) enum Error {
|
|||
I2cFailure(i2c::Error),
|
||||
#[error("Failed while parsing to integer: {0:?}")]
|
||||
ParseFailure(ParseIntError),
|
||||
#[error("Failed to join threads")]
|
||||
FailedJoiningThreads,
|
||||
#[error("Could not create backend: {0}")]
|
||||
CouldNotCreateBackend(vhu_i2c::Error),
|
||||
#[error("Could not create daemon: {0}")]
|
||||
|
|
@ -215,7 +213,7 @@ fn start_backend<D: 'static + I2cDevice + Send + Sync>(args: I2cArgs) -> Result<
|
|||
}
|
||||
|
||||
for handle in handles {
|
||||
handle.join().map_err(|_| Error::FailedJoiningThreads)??;
|
||||
handle.join().map_err(std::panic::resume_unwind).unwrap()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue