> For the complete documentation index, see [llms.txt](https://chihaolu.gitbook.io/all-in-one-solidity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chihaolu.gitbook.io/all-in-one-solidity/part-ii-medium/chapter-9-yi-chang-chu-li-handling-exception/revert.md).

# 【Revert】

`revert()` 用於確認複雜狀態，意思就是說我們必須寫上一連串的巢狀 if-else 或其他條件式選擇來過濾各種情形，最後才加上 `revert()` 如果我們進到了錯誤結果。

```solidity
pragma solidity ^0.8.11;

contract error {
    function testRevert(uint _i) public pure {
        if (_i <= 10) {
            if (_i != 10){
                revert("Input must be equal 10");
            }
        }
    }
}
```

Revert會回復交易狀態，與其他的異常處理語法比較可見下列比較例子：

```solidity
if (amount > msg.value ether){
    revert("Not Enough Ether Provided");
}
// Alternative way to fdo it:
require(amount <= msg.value ether, "Not Enough Ether Provided");
```
