Support converting error-chain into Failure::Error
elichai opened this issue · comments
Hi,
I use Failure::Error
in my code, and when I try to use try!
on a function that returns an error from the error_chain!
macro by the error-chain crate it fails with the following error:
error[E0277]: `(dyn std::error::Error + std::marker::Send + 'static)` cannot be shared between threads safely
--> w3utils.rs:61:19
|
61 | return Ok(ethabi::Contract::load(rdr)?);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn std::error::Error + std::marker::Send + 'static)` cannot be shared between threads safely
|
= help: the trait `std::marker::Sync` is not implemented for `(dyn std::error::Error + std::marker::Send + 'static)`
= note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<(dyn std::error::Error + std::marker::Send + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn std::error::Error + std::marker::Send + 'static)>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn std::error::Error + std::marker::Send + 'static)>>`
= note: required because it appears within the type `error_chain::State`
= note: required because it appears within the type `ethabi::Error`
= note: required because of the requirements on the impl of `failure::Fail` for `ethabi::Error`
= note: required because of the requirements on the impl of `std::convert::From<ethabi::Error>` for `failure::Error`
= note: required by `std::convert::From::from`
Now I found an issue on error-chain
asking to add Sync support but it doesn't look like anyone is working on it. ( rust-lang-deprecated/error-chain#240 )
Maybe the solution can be from failure? adding some sort of From
trait for the error-chain
crate?
I would like to know what you guys think,
Thanks.
There's something, would this help you? https://docs.rs/failure/0.1.3/failure/struct.SyncFailure.html
Hi! I have the same problem, and manually doing .map_error(SyncFailure::new)
works, but it's not very ergonomic if you have to repeat it several times.
I wonder if there's a better way for integrating with error_chain
.
Also, I have the same problem with integrating futures
and failure
: CallFuture::wait
returns Result
parametrized by (dyn std::error::Error + std::marker::Send + 'static)
.