-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Problem
Returning precise error codes and informative error messages for AVM runtime failures is crucial for the Smart Contract clients (and overall user experience).
Solution
Include a native Algorand Python way to handle Smart Contract errors.
Common standard formatting, codes and messages should be harmonized with an ARC (e.g. 401:Unauthorized Caller).
Proposal
A base BaseError class with with standard errors (standard error_codes and harmonized error_messages) which can be inherited and extended as Error(BaseErrors) with Smart Contract specific error codes and messages.
Additionally, would be good to have utilities like: add_error(code: int, message: str) -> Error which automatically formats the error etc.
This would combine nicely for tests, like in pytest where you can do:
with pytest.raises(LogicError, match=Error.A_STANDARD_ERROR):so that you write a test that expects a specific error code.
Pros and Cons
Pros: fostering the standardization of Smart Contract error codes and messages in the ecosystem.
Cons: I can not see any.
Dependencies
None