# 【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");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chihaolu.gitbook.io/all-in-one-solidity/part-ii-medium/chapter-9-yi-chang-chu-li-handling-exception/revert.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
