Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Support converting error-chain into Failure::Error #284

Open
elichai opened this issue Dec 19, 2018 · 2 comments
Open

Support converting error-chain into Failure::Error #284

elichai opened this issue Dec 19, 2018 · 2 comments

Comments

@elichai
Copy link

elichai commented Dec 19, 2018

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.

@vorner
Copy link

vorner commented Dec 28, 2018

There's something, would this help you? https://docs.rs/failure/0.1.3/failure/struct.SyncFailure.html

@folex
Copy link

folex commented Jan 22, 2019

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants