-
Notifications
You must be signed in to change notification settings - Fork 590
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
error-handling: simplify boxed error definition #13215
Comments
Ohhhhh, so basically, you are just summarize some current practice into a paradigm (with ergonomic macros), right? You are not introducing new patterns. |
Let me summarize my understanding, and some questions included: (Some of) Our current practice is enum The core idea is we added a layer of indirection. Benefits are:
Limitations are:
comments: I feel the BTW, I also feel the pattern is kind of similar to a "statically-typed" version of |
You know me really well! 😄
You're right. The key motivation is still to box it. Ability to add backtrace is just a by-product.
Yes. Always adding a backtrace may not be the best practice since...
I'll add the support with an option provided in the future.
Didn't think you notice that. 😄 Yeah, it's really easy to reuse all
Not only that, there'll also be some extensions traits generated for
Yeah. Since the constructors should be generated on the public wrapped type, I find
You're pretty correct. However, the benefits of static type could be:
|
Thanks for your reply! Pretty clear. Glad I understood it correctly. |
Background: #11443.
thiserror
is good and self-contained until we have to customize it, among of which definining a wrapper of the error enum is the most frequent one.risingwave/src/stream/src/error.rs
Lines 30 to 45 in c7eada9
The reason for wrapping is...
box
it after constructing.However, wrapping makes the interface of
thiserror
not that user-friendly as before.All
#[from]
in the enum does not work any more. There's an extra conversion step from theExternalError
toErrorInner
thenError
.risingwave/src/stream/src/error.rs
Lines 101 to 106 in c7eada9
thiserror
annotations like#[from]
and#[source]
, since they seem useless. However, they're really critical since they help us to maintain thesource
chain of an error.risingwave/src/common/src/error.rs
Lines 98 to 99 in c7eada9
Constructing an error is more painful.
risingwave/src/frontend/src/binder/delete.rs
Lines 77 to 79 in c7eada9
risingwave/src/stream/src/executor/error.rs
Lines 91 to 98 in c7eada9
As the result, in #11275, we choose another way to reduce the stack size by boxing each variant separately. However, this still breaks
From
.Then I'm planned to simplify this procedure with proc-macros. See linked PR for details.
The text was updated successfully, but these errors were encountered: