Open withoutboats opened 6 years ago
I believe I'm being hit by a problem of my errors being !Sync
. I'm implementing Read
and Write
, so I'm trying to wrap my errors in an io::Error
. This should be easy, but it's impossible if my error is !Sync
, because io:Error
requires it to be Sync
.
This would be beneficial for those that don't want to lose the type-safety of error-chain
but have to interface with crates using failure
!
Agreed, wish there was at least an adapter out of the box. I'm having to translate my errors at the moment and it's a hassle :D
I just run into this too it's quite a bumper and very depressing if it's in a (opt) dependency and you have to have Sync errors because of another dependency/software architecture/...
I fully switched to failure as I find it to be a more robust and cross-cutting approach than error_chain that doesn’t do as much wrapping of dependency error types but instead promotes that you maintain your own errors and contexts, particularly when culminating many libs together into an application and working with all the error types.
On Thu, May 31, 2018 at 8:12 AM Philipp Korber notifications@github.com wrote:
I just run into this too it's quite a bumper and very depressing if it's in a (opt) dependency and you have to have Sync errors because of another dependency/software architecture/...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rust-lang-nursery/error-chain/issues/240#issuecomment-393510335, or mute the thread https://github.com/notifications/unsubscribe-auth/AABPq0PhtK0QZO4NxOKqK3o4vEbsXVnwks5t394ngaJpZM4QXLNc .
-- Sent from Gmail Mobile
Any news about this?
This cause a lot of troubles if you use failure::Error
but use a library that uses error-chain
Nobody seems to have disagreed with the thrust of this bug, but there are no PR's implementing it either (or at least not tagged appropriately), so its probably in the category of help-wanted.
Oh huh, there it is. Ta. https://github.com/rust-lang-nursery/error-chain/pull/241 Now I need to figure out how to get that to happen :P.
One mildly ugly workaround if anyone else needs it is an adapter like this. Its not as pretty as straight coercion, but it does allow interop for things like anyhow and failure and so-on (more generically than the failure::SyncFailure that inspired it).
I created a pull request that adds 'Sync' using a feature flag if anyone wants to check it out https://github.com/rust-lang-nursery/error-chain/pull/300
The failure crate requires that errors are
Sync
. Currently (but not in all previous versions) error-chain makes errors which are!Sync
(because they have aBox<Error + Send>
inside them).It would be beneficial IMO to: