-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve nested error handling #942
Conversation
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.
LGTM 🎉
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.
Good idea! Simple and elegant solution.
Just one NIT, otherwise LGTM.
@@ -396,7 +371,7 @@ impl From<SwapError> for ReceiveOnchainError { | |||
impl From<PersistError> for ReceiveOnchainError { | |||
fn from(err: PersistError) -> Self { | |||
Self::Generic { | |||
err: format!("Error when accessing local DB: {err}"), | |||
err: err.to_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.
IMO the previous prefix was useful here, to help us pin-point this to a persister issue.
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.
So the error previously would be:
Generic: Sql: Error when accessing local DB: <rusqlite::Error>
would this be better for SQL errors?
Generic: Error when accessing local DB: <rusqlite::Error>
I would apply this to the enum so all outward facing errors get the same
pub enum PersistError {
...
#[error("Error when accessing local DB: {0}")]
Sql(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.
The top one is best:
Generic: Sql: Error when accessing local DB: <rusqlite::Error>
I was only pointing out that the Error when accessing local DB
prefix seemed to be removed, as I found it nowhere else in the code.
432b723
to
6181f61
Compare
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.
LGTM
This PR aims to remove wrapping of error strings rendered from nested errors within the SDK. The result being only outwardly facing errors prefix their variant name to the error string
Example 1:
Example 2:
Inspired by #885, but may not solve the Flutter issue