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>
| /// 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.
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::ErrorRequire 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 Fromforces 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.thiserrorvssnafuAs I mentioned in
thiserrorvssnafudiscussion, the hugekube::Erroris a problem I'd like us to start fixing. I've been using boththiserrorandsnafu, and I think usingthiserrorwithout#[from], and gradually breaking errors down is probably the best approach forkube. While I thinksnafuhelp 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
thiserroris stable (v1).snafuis still evolving. 0.7 will addSnafusuffix 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
thiserrorv1 is used by 9,491 public crates.snafu0.6 is used by 270.snafuis extra dependency for many.Features
snafuprovides some syntactic sugars, but I don't think it adds that much value. Avoiding#[from]and using the usualResult::map_errfeels similar enough, especially as we break the errors down.One feature
snafuoptionally provides thatthiserrordoesn't, is backtrace in stable, but this requires the end users to depend onsnafuand enable thebacktracefeature. There are error reporter crates to do this until backtrace become stable.Unless I missed something significant, I think we should go with
thiserrorwithout#[from].