异常处理
断言assert(bool condition)
assert(bool condition),如果条件不满足,抛出异常,合约中断,一般使用在内部错误。
要求require
require(bool condition),如果条件不满足,抛出异常,合约中断,在函数输入参数和外部函数使用。
require(bool condition, string message),提供一个错误信息。
回滚revert()
revert(),中断合约执行,回滚状态改变。
revert(string reason),提供一个回滚说明。