How do you throw a custom error in Solidity?

Responsive Ad Header

Question

Grade: Education Subject: Support
How do you throw a custom error in Solidity?
Asked by:
44 Viewed 44 Answers

Answer (44)

Best Answer
(254)
You throw a custom error using the `revert` keyword followed by the error name and any associated data. For example: `revert InsufficientBalance(available, required);` or `revert MyError(someData);`. If it's an anonymous error, you simply use `revert;`.