-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Start Refining Errors #686
Conversation
Big 👍 on the overall idea.
That makes sense to me.
Definitely, it's all just syntax sugar in the end.
While it'd be nice to only depend on one of them in the end, we don't need to go all-in from the start. Neither of them are visible in the public API, and they interoperate just fine (aside from SNAFU's backtraces).
I'm not looking forward to that upgrade, but there's also no huge rush. We're not holding anyone else back from upgrading since we're only exposing the
To be honest I kind of dislike tuple variants anyway, since they become quite messy as soon as you want to add any extra context to the errors, as demonstrated by your file example. I'd feel much more comfortable pattern-matching |
To be clear: even if I might personally prefer going full SNAFU, (IMO) modularized thiserror is still a vast improvement over what we currently have. |
Yeah, I like this a lot as well. Gets us going on refining.
This justification is good. The popularity of Regardless of how pointless a popularity contest may seem, pretty much everyone knows how to wrangle |
Cool, I'll open a tracking issue with a summary and task list.
Yeah, we should avoid tuple if it makes the error difficult to use. We should decide what's best for each error, and |
c2f1faa
to
8931e04
Compare
Require explicitly mapping errors. This commit shows how much we need to mentally process while reading the code (maintenance cost), and how badly grouped they are (usability issue). Removing `impl From` forces us to attach context. Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
Signed-off-by: kazk <kazk.dev@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me! Generally just minor nits. But but have one question left on our approach w.r.t. #515 .
@@ -26,7 +26,7 @@ use kube_core::{ | |||
/// ```no_run | |||
/// use kube::{Client, api::{Api, DynamicObject}, discovery, ResourceExt}; | |||
/// #[tokio::main] | |||
/// async fn main() -> Result<(), kube::Error> { | |||
/// async fn main() -> Result<(), Box<dyn std::error::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside here; I think we probably should move our docs to use an async fn wrapper here ala https://github.com/kube-rs/kube-rs/blob/master/kube-runtime/src/events.rs#L134 to reduce the docs cruft everywhere (not necessary in this PR)
Signed-off-by: kazk <kazk.dev@gmail.com>
I wanted to add "Refine Errors" (opened #688) to our roadmap, so I tried a bit to see how we can tackle this. Any feedback is appreciated.
Remove
impl From<T> for kube::Error
Require explicitly mapping errors.
This commit shows how much we need to mentally process while reading the code (maintenance cost), and how badly grouped they are (usability issue).
Removing
impl From
forces us to attach context, and this is a good thing. It's verbose right now, but that's because we need to break them down.As an example, I got rid of
kube_core::Error
. Parsing group version no longer has an error variantHttpError
.thiserror
vssnafu
As I mentioned in
thiserror
vssnafu
discussion, the hugekube::Error
is a problem I'd like us to start fixing. I've been using boththiserror
andsnafu
, and I think usingthiserror
without#[from]
, and gradually breaking errors down is probably the best approach forkube
. While I thinksnafu
help us initially to think of errors in a more scalable way, it's not necessary to implement the pattern. Also, we probably can't do SNAFU way until we finish breaking them down cleanly anyway, and the features to prevent misuse will get in the way (e.g., private context selectors by default). So, I don't think it's worth some downsides.Stability
thiserror
is stable (v1).snafu
is still evolving. 0.7 will addSnafu
suffix to generated context selectors. Tuple variants are not well-supported? (I haven't used tuple variants withsnafu
, so I don't know the details).Popularity
thiserror
v1 is used by 9,491 public crates.snafu
0.6 is used by 270.snafu
is extra dependency for many.Features
snafu
provides some syntactic sugars, but I don't think it adds that much value. Avoiding#[from]
and using the usualResult::map_err
feels similar enough, especially as we break the errors down.One feature
snafu
optionally provides thatthiserror
doesn't, is backtrace in stable, but this requires the end users to depend onsnafu
and enable thebacktrace
feature. There are error reporter crates to do this until backtrace become stable.Unless I missed something significant, I think we should go with
thiserror
without#[from]
.