-
Notifications
You must be signed in to change notification settings - Fork 41
Description
std::error::Error now contains a trait as expressive as the Fail
trait from failure
, including downcast support and downcastable Error::source as a replacement for Error::cause
(now with a 'static
lifetime bound).
Additionally, there are a number of custom derive crates for std::error::Error
now available:
Given that, it seems like we can eliminate failure
as a dependency, potentially replacing failure_derive
with one of the crates above.
Serializable Errors
A bit of a sidebar, but one of the things I'd like to eventually accomplish is serde
support for the framework's Error
type, making it Serialize
-able (and ideally Deserialize
-able as well), with the intent of serializing them as JSON for reporting to an exception reporting service.
The backtrace
crate offers serde
support as an optional feature, however accessing this functionality was previously difficult as Abscissa's Error
type uses failure::Context to capture and store backtraces.
It seems like Abscissa could benefit from providing a similar Context
type as a replacement for the one failure
provided. Ideally this type could simply derive(Serialize, Deserialize)
, permitting straightforward serialization of errors as well as their backtraces (and ideally, the entire error chain).
Unfortunately the story around all of this is complicated by adding a Backtrace
type to std
, presently only available on nightly
. This Backtrace
type has deliberately minimal functionality.
I'd consider supporting Backtrace
on stable a requirement, and ideally preserving the serde
serialization support. This seems possible with snafu
but needs more investigation.
Crates like err-derive
and thiserror
have the advantage of being pure proc macros with no additional API dependencies, so if nothing else they stay nicely out of the way and orthogonal to this problem. I imagine if we don't go with snafu
, we could pick one of these to be the out-of-the-box custom derive for errors, but with the only framework-level association being inclusion in the default application template (allowing downstream users of the users to potentially remove it or swap it out if they so desire)