Merge two similar sections; the original survives

This commit is contained in:
Yoichi Hirai 2016-10-10 22:24:59 +02:00
parent 03ef5bfd5e
commit d6394c46a1
2 changed files with 8 additions and 23 deletions

View File

@ -324,12 +324,14 @@ In the following example, we show how ``throw`` can be used to easily revert an
Currently, there are six situations, where exceptions happen automatically in Solidity:
1. If you access an array beyond its length (i.e. ``x[i]`` where ``i >= x.length``).
2. If a function called via a message call does not finish properly (i.e. it runs out of gas or throws an exception itself).
3. If a non-existent function on a library is called or Ether is sent to a library.
4. If you divide or modulo by zero (e.g. ``5 / 0`` or ``23 % 0``).
5. If you perform an external function call targeting a contract that contains no code.
6. If a contract-creation call using the ``new`` keyword fails.
1. If you access an array on or beyond its length (i.e. ``x[i]`` where ``i >= x.length``) or below zero.
2. If you access a fixed-length bytes on or beyond its length, or below zero.
3. If a function called via a message call does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` is used.
4. If a non-existent function on a library is called or Ether is sent to a library.
5. If you divide or modulo by zero (e.g. ``5 / 0`` or ``23 % 0``).
6. If you perform an external function call targeting a contract that contains no code.
7. If a contract-creation call using the ``new`` keyword does not finish properly.
8. If a contract is called but there are no matching interface or fallback function.
Internally, Solidity performs an "invalid jump" when an exception is thrown and thus causes the EVM to revert all changes made to the state. The reason for this is that there is no safe way to continue execution, because an expected effect did not occur. Because we want to retain the atomicity of transactions, the safest thing to do is to revert all changes and make the whole transaction (or at least call) without effect.

View File

@ -56,23 +56,6 @@ So for the following contract snippet::
The position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``.
********************
When Solidity Throws
********************
A Solidity contract throws an exception for unhealthy operations such as
- division by zero
- modulo by zero
- out-of-bounds index access on an array
- out-of-bounds index access on a fixed-length bytes
- an Ether transfer through an interface function that is not specified as ``payable``
- execution of ``throw;``
- a contract invocation with no matching interface or fallback function
- an external call in an exceptional state, for instance, out of gas, invalid jump destination, and so on (however, low level ``call``, ``send``, ``delegatecall`` and ``callcode`` just return zero for such cases)
- an external call on a Solidity contract that throws (again, if the external call is made through a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` the caller does not throw an exception but just sees a zero return value by default)
*****************
Esoteric Features
*****************