-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crates: Replacements for failure? #144
Comments
I think that this issue mixes two distinct questions, assuming the goal is to replace all uses of the
Currently, Abscissa uses The answer to question (1) seems relatively less important to Abscissa users, because any answer to question (1) is an implementation detail for Abscissa. The answer to question (2) seems relatively more important, because any answer shows up in the public API. Two possible answers to question (2) are:
As an Abscissa user, I would strongly prefer having all generic errors be bounded with |
I'd be fine with defining a framework level boxed error type. See the "Proposal: add std::error::BoxError" rust-internals thread which explores various tradeoffs regarding how it should be defined. The main problem with using that as "the"
|
FWIW, I just thought I'd drop in and add that I'm currently experimenting with a |
@hawkw very cool. It'd be quite interesting if it were possible to trace things like asynchronous events which originate in an RPC request but the fire off some sort of background job (kind of like an in-process equivalent of the similar functionality in Dapper/Zipkin/OpenTracing).
I'd almost certainly want that |
One quick note on backtrace capture in general: it seems like the best option there (and the direction the Unfortunately that pulls in a large number of dependencies today, so I'm wary to enable It would be easy enough to add an off-by-default Cargo feature to enable them, however, and a commented-out line in the application boilerplate template to optionally enable it (in which case I'd also turn it on in all of my personal apps). |
Yup, that's more or less the exact goal I had in mind! :)
When I get around to adding stack backtraces to a |
Since the time `failure` was written, `std::error::Error` has gained many of the features it was originally useful for, most notably `Error::source` for type erased error chains/cascades (with downcast support to recover the concrete type, if desired), and on `nightly`, backtrace support. This commit attempts to remove `failure` in a way that largely preserves the existing error handling, replacing `failure::Context` with an internal `abscissa_core::error::Context` type which provides similar functionality. Additionally, it defines a `BoxError` alias for type-erased errors based on ideas from this rust-internals thread: https://internals.rust-lang.org/t/proposal-add-std-boxerror/10953/1 It's bounded as `Send + Sync + 'static` to help in multithreaded/async contexts. I'm not convinced this is good as a steady state, but rather could also be a stepping stone towards moving to some more widely supported library, as discussed in #144.
I added an https://github.com/iqlusioninc/abscissa/pull/151/files#diff-11635f54908685fd908957a138677245R14 |
Here's a comprehensive analysis of various popular Rust error handling libraries, what features they provide, and how they relate to each other: |
Now that v0.5.0 is out and I'm updating a lot of apps which previously used I think it'd be worth including in the framework boilerplate (but not necessarily as a framework-level dependency). This could be done in a v0.5.1 release of the |
Add `thiserror` to default application boilerplate (closes #144)
As of #188, |
std::error::Error now contains a trait as expressive as the
Fail
trait fromfailure
, including downcast support and downcastable Error::source as a replacement forError::cause
(now with a'static
lifetime bound).Additionally, there are a number of custom derive crates for
std::error::Error
now available:err-derive
snafu
thiserror
Given that, it seems like we can eliminate
failure
as a dependency, potentially replacingfailure_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'sError
type, making itSerialize
-able (and ideallyDeserialize
-able as well), with the intent of serializing them as JSON for reporting to an exception reporting service.The
backtrace
crate offersserde
support as an optional feature, however accessing this functionality was previously difficult as Abscissa'sError
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 onefailure
provided. Ideally this type could simplyderive(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 tostd
, presently only available onnightly
. ThisBacktrace
type has deliberately minimal functionality.I'd consider supporting
Backtrace
on stable a requirement, and ideally preserving theserde
serialization support. This seems possible withsnafu
but needs more investigation.Crates like
err-derive
andthiserror
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 withsnafu
, 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)The text was updated successfully, but these errors were encountered: