Explanation of what error codes are and how to handle them in your code
Like Compound, just because a transaction was successful does not mean it actually did what we expected. Cozy inherited some of Compound's error handling approaches, which means a transaction may be successful—and show as successful on Etherscan and other block explorers—but in reality it didn't succeed. This is because some failed transactions will return an error code and emit a
Failureevent instead of reverting. You can find Compound's error codes here, and a brief history of why it's handled this way here.
This approach can be a bit tedious for users and developers, as we now we have to manually ensure our transaction succeeded before continuing to the next step. In the Cozy Developer Guides repo you'll find a method called
utils/utils.tsfolder to help you with this.
This method searches for the expected success log in a transaction and returns it if found. If it's not found, an error is thrown and the
Failureerror codes are reported. You can compare those error codes to those in the table below to learn why your transaction failed.
Error codes are defined in
ErrorReporter.soland provided here for convenience.
If an error code was emitted from a transaction to the Comptroller, refer to these error codes.
Error codes 0–17 are identical to Compound's. Error codes 18 and 19 are unique to Cozy.
If an error code was emitted from a transaction to a Cozy Token, refer to these error codes.
If an error code was emitted from a transaction to the Protection Market Factory, refer to these error codes.
If an error code was emitted from a transaction to the Oracle, refer to these error codes.