94 - catch Blocks
Solidity supports different kinds of catch blocks depending on the type of error:
-
catch Error(string memory reason) { ... }
: This catch clause is executed if the error was caused by revert("reasonString") or require(false, "reasonString") (or an internal error that causes such an exception). -
catch Panic(uint errorCode) { ... }
: If the error was caused by a panic, i.e. by a failing assert, division by zero, invalid array access, arithmetic overflow and others, this catch clause will be run. -
catch (bytes memory lowLevelData) { ... }
: This clause is executed if the error signature does not match any other clause, if there was an error while decoding the error message, or if no error data was provided with the exception. The declared variable provides access to the low-level error data in that case. -
catch { ... }
: If you are not interested in the error data, you can just usecatch { ... }
(even as the only catch clause) instead of the previous clause.
catch Error(string reason)
catch Panic(uint errorCode)
catch (bytes memory LowLevelData)
catch