-
Notifications
You must be signed in to change notification settings - Fork 1
KOL-5 | feat: Enhance error handling with detailed KolmeError variants #403
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
base: main
Are you sure you want to change the base?
Conversation
Deploying kolme with
|
| Latest commit: |
aab096d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e2411421.kolme.pages.dev |
| Branch Preview URL: | https://kol-5.kolme.pages.dev |
snoyberg
left a comment
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.
Left some comments for a change in general direction. When this is ready for another review, let's get @MichaelNelo on this too so I'm not a bottleneck.
2efdafe to
a75f49d
Compare
|
@borsboom, Michael asked me to work with you in this PR. |
|
@anakinzhed I'm still familiarizing myself with the Kolme codebase, and this is a big PR. I'm working to understand the changes and figure out if there's a way we can avoid the stringy errors that are hard to avoid because of the traits that KolmeError derives. It might take me a little while to respond further, but I am working on it. |
borsboom
left a comment
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.
Not easy to retrofit proper errors into a codebase like this, especially given the need for some errors to be serializable.
Aside from the comments I added to specific changes, I noticed there are still many uses of anyhow::Result which end up being "hidden" by error types implementing From<anyhow::Error> and stringifying them. Removing those, and any imports of anyhow::Result should help find them (as well as just searching the codebase anyhow).
|
@borsboom Sorry for the delay. I believe I’ve addressed all of your comments. Please take a look. |
|
Great progress! I notice there are still some places that are returning Better would be for the functions to return a concrete error (e.g. pub enum KolmeExecuteError {
…
#[error("Public key error: {0}")]
PublicKeyError(#[from] shared::cryptography::PublicKeyError),
}If at all possible, |
|
@borsboom I made several changes. Please take a look and let me know your thoughts. |
borsboom
left a comment
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 is getting really close. Most of these comments are nitpicks which you can disregard if you don't think they're worth addressing.
My biggest question is about TransactionError::StoreError and ::CoreError and why they take Strings, because if feels like that may be due to some kind of structural issue. If you can explain the reason, I might be able to help find another approach.
I pushed a commit that removes the anyhow dependency from kolme and kolme-store's Cargo.tomls, and removed a few remaining places that referenced it (one of which was in code I added recently, which is why I figured it made sense for me to take care of it).
| #[derive(thiserror::Error, Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
| pub enum TransactionError { | ||
| #[error("Store error: {0}")] | ||
| StoreError(String), |
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.
Why are StoreError and CoreError both strings instead of concrete types? Is there a way to avoid this? I'd like to understand so maybe we can find another approach.
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.
The problem here is that TransactionError must be Clone, serde::Serialize, and serde::Deserialize in order to be sent, but KolmeCoreError and KolmeStoreError do not derive Clone, serde::Serialize, or serde::Deserialize.
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.
@borsboom This is the only remaining open point. The reason is explained in the message above. I don’t currently see another way to handle this, so please if you have a better approach in mind, please let me know. Thanks!
No description provided.