You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
Hey there, I'm writing another library, which needs users to be able to define their own errors and compose them with other users' error types. I was hoping simply requring users to define their errors with error-chain would solve this problem, but I'm having some trouble.
Specifically, I'd like:
E: ChainedError gives me a way of performing a conversion for<F: ChainedError> F => E. That is, I can convert any ChainedError into any other ChainedError. Though the library may generate specific impls that enable this (seems like the ResultExt does this), there's no trait abstraction of this operation allowing me to deploy it in a generic context.
The same thing, but for<F: std::error::Error> F => E. That is, I can convert any Error into any ChainedError. This may be trickier, of course, because it may require creating a Box<Error>, and may be less preferential than explicit links for this reason (though I sort of don't agree that avoiding dynamic dispatch in the error path is significantly beneficial).
Is it possible for either of these to be provided? Unfortunately orphan rules prevent any impl of From<X> for T: ChainedError, and without HRTB of types you can't bound ChainedError: for<X> From<X> either. But even if I had to be explicit, that would be better than being unable to do it.
The text was updated successfully, but these errors were encountered:
Hey there, I'm writing another library, which needs users to be able to define their own errors and compose them with other users' error types. I was hoping simply requring users to define their errors with error-chain would solve this problem, but I'm having some trouble.
Specifically, I'd like:
E: ChainedError
gives me a way of performing a conversionfor<F: ChainedError> F => E
. That is, I can convert any ChainedError into any other ChainedError. Though the library may generate specific impls that enable this (seems like the ResultExt does this), there's no trait abstraction of this operation allowing me to deploy it in a generic context.for<F: std::error::Error> F => E
. That is, I can convert any Error into any ChainedError. This may be trickier, of course, because it may require creating aBox<Error>
, and may be less preferential than explicit links for this reason (though I sort of don't agree that avoiding dynamic dispatch in the error path is significantly beneficial).Is it possible for either of these to be provided? Unfortunately orphan rules prevent any impl of
From<X> for T: ChainedError
, and without HRTB of types you can't boundChainedError: for<X> From<X>
either. But even if I had to be explicit, that would be better than being unable to do it.The text was updated successfully, but these errors were encountered: