-
Notifications
You must be signed in to change notification settings - Fork 8
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
Convert TezosKitError to enum type #185
Conversation
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
==========================================
- Coverage 53.85% 53.58% -0.28%
==========================================
Files 102 102
Lines 3281 3281
==========================================
- Hits 1767 1758 -9
- Misses 1514 1523 +9
Continue to review full report at Codecov.
|
} | ||
|
||
// Check for \"status\":\"backtracked\" in the response, indicating a failed transaction being rolledback | ||
if stringData.contains("\"status\":\"backtracked\"") { |
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.
@keefertaylor can you try take the code I had for catching backtracks in the other PR and replace this block with it. Feel free to refactor again, update, rename etc. But I can't update to the latest code until thats in it as it will break our app. Once you have that you can close my error handling PR entirely.
Also I came across another issue that mine wasn't catching either. If you use a customFeePolicy and set it too low (by accident). Because the estimation is never called it doesn't catch gas errors. When that happens you get a .success(let opHash)
back from the tezosKit send
, but the console will have "protoxxx.gasExhausted....." in it. Would be great to try catch that too
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.
Acked on the gasExhaused. Filed #190
Hey @simonmcl, I added your logic in. I added a new error type, I also added a TODO for myself to add a test here. It should be easy to come up with some fake data and ensure that we parse these errors correctly and that would help us prevent future regressions. If you happen to have an example of a response with one of these errors on hand, I'd be grateful if you could share. LMK what you think. |
@keefertaylor sure, below is the gas exhausted error when using hardcoded gas costs. The structure of the other errors is in this PR: #183 . I replaced some of the large objects with
|
Code looks good. I'll give it all a proper test in the app once its all merged. I have some transaction history code that needs to be merged in after |
Cool. I'm going to land this code as is and then follow up on the gas exhausted stuff. |
Early on in this project I made the (stupid) choice to make errors
struct
s instead ofenum
s. This has lead to problematic code where underlying errors are always optional and are often just untyped strings.As TezosKit handles more complex interactions, it may be useful to return arrays of errors, typed errors or to know that there is no additional data associated with an error.
This breaking change moves error handling to enums with associated values. In essence, this is a prefactor for #183 / #179.