Using a `failure::Error` as a cause / `Error::into_fail()`
Diggsey opened this issue · comments
It's difficult to allow arbitrary causes when deriving Fail
, because failure::Error
does not implement Fail
, and so cannot be used as a cause.
At the moment, you can use error.compat()
to turn it into a type implementing Fail
, but this results in the backtrace and further cause information being thrown away.
I think a better solution would be for failure::Error
to provide an into_fail()
method which returns a Box<Fail>
. Now custom types can store a Box<Fail>
as their cause and still derive Fail
(because Box<Fail>
implements Fail
).
Would AsFail handle your use case?
Yes, it would!