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
I have to use multiple internal crates which mix and match anyhow and eyre. When trying to convert between the two, I have convert anyhow::Error to Box<dyn Error>, which then complains that conversion requires dyn Error to be Sized (in order for Box to implement Error). This results in this ugly solution when using Result<Something, ThinError>:
result
// Both `anyhow::Error` and `eyre::Report` support conversion into `Box`.map_err(Into::<Box<dynError + Send + Sync>>::into)// However, I have to stuff it into `Arc` which implements `Error` for `?Sized`.map_err(Into::<Arc<dynError + Send + Sync>>::into)?
Is there a better solution to this? If not, would it be possible to add conversion implementation from anyhow::Error into Arc or something equivalent? Unfortunately, I am unable to implement it, as it would require use of unsafe (with which I do not have enough experience) and because I am unfamiliar with techniques used in anyhow thinning.
Thank you very much in advance.
The text was updated successfully, but these errors were encountered:
Because it implements From<E> where E: Error, which would clash with blanket implementation (you can convert any type into itself). It's the same reason for Box complains about Sized constraint to implement Error.
I solved this by wrapping anyhow::Error in newtype and implementing Error for that.
Hello,
I have to use multiple internal crates which mix and match
anyhow
andeyre
. When trying to convert between the two, I have convertanyhow::Error
toBox<dyn Error>
, which then complains that conversion requiresdyn Error
to beSized
(in order forBox
to implementError
). This results in this ugly solution when usingResult<Something, ThinError>
:Is there a better solution to this? If not, would it be possible to add conversion implementation from
anyhow::Error
intoArc
or something equivalent? Unfortunately, I am unable to implement it, as it would require use of unsafe (with which I do not have enough experience) and because I am unfamiliar with techniques used inanyhow
thinning.Thank you very much in advance.
The text was updated successfully, but these errors were encountered: