Error
In Solidity, developers can define errors in three main forms: revert, require, and assert. The main differences between these methods from a functional perspective are two-fold:
- Whether they can throw developer-defined error reasons;
- Whether they can throw developer-defined errors carrying variables;
The main differences are as follows:
| Type | Custom Reason | Carries Variable | Example |
|---|---|---|---|
revert | ✅ | ✅ | Reason: UnauthorizedAccess(0x05D01CAF54524A610CCF187082201120757f7AE5) |
require | ✅ | ❌ | Reason: UnauthorizedAccess |
assert |