Error-chain and threads


I’ve got my program running with error_chain, which saved me a bunch of boilerplate. Now I get the error chain info I want everywhere except when the error originates in a thread. I’m using crossbeam, so my code looks like

function spawner(scope: &Scope) -> Result<()> {
    scope.spawn( move || -> Result<()> {
	fn_that_returns_an_error().chain_err(|| "reason")

I know the error occurs, but the error chain doesn’t propagate the way it does in the mainline code. Do I have to resort to match or map_err when inside a thread?


spawn returns a ScopedJoinHandle, that you can use to to join the thread (meaning to wait for it to finish) and get back its result. Otherwise that thread’s result is lost.