Refactor TransactionErr and TPU events to make them more structured and distinctive #2226
Labels
improvement: error handling
Improvements made on error-handling
priority: high
Important tasks that need attention soon.
Problem:
Currently the main variant to convey transaction errors is TransactionErr::Plain(String).
In some cases, when error needs a user reaction, passing errors in String is not convenient for the GUI to process it.
For e.g. in case of insufficient funds in a withdraw or simply send_raw_transaction call to Eth network we return this error as a string
code: ServerError(-32000), message: \"insufficient funds for gas * price + value: balance ... , tx cost ..., overshot ...
.A multilingual GUI can't just display such an error so it would need to parse it by itself to react (this is what komodo-wallet actually does).
In case of Ethereum the network does not return a specific code for errors like 'insufficient funds' and I believe this is a task for the API to process them and return as structured errors (for e.g. etherjs code does this).
Another case is swap events reflecting failures during the swap. They contain enums like AbortReason, MakerPaymentRefundReason, TakerPaymentRefundReason. Again such objects have attached TransactionErr, ValidatePaymentError errors simply converted to a String. This makes it harder for GUI to show what wrong happened during the swap. Better to make those String descriptions as structured error with error_type and optional params. For example:
{ "error_type": InsufficientFunds", "available": 1000, "required": 1200 }
.It's probably not necessary to refactor errors in legacy swap events as we target TPU.
Solution
The text was updated successfully, but these errors were encountered: