Migrate away from failure
@amesgen advises to use a different error handling library. This is now or never.
Can you please elaborate on why it is cumbersome?
- The development of
failure
has stalled (see e.g. https://github.com/rust-lang-nursery/failure/issues/287 ). - The
std::error::Error
trait has been improved since the release offailure
. The problematic thing is thatfailure::Error
does not implementstd::error::Error
, which makes it cumbersome to use if I useBox<dyn std::error::Error + Send + Sync>
oranyhow::Error
or something similiar as my error type. Also see https://github.com/dtolnay/anyhow#comparison-to-failure
That is how error handling works with failure. Our
Result
type is the same asfailure::Fallible
. You can downcastfailure::Error to
the concrete type.
Ah, I forgot about downcasting. IMHO, the approach of having separate crates for an universal error type (anyhow
) and deriving std::error::Error
(thiserror
) is somewhat better, as it enables libraries to use std::result::Result<A, MyCustomErrorType>
with MyCustomErrorType: std::error::Error
directly. Also see https://github.com/dtolnay/anyhow#comparison-to-thiserror