diff options
author | Denton Liu <liu.denton+github@gmail.com> | 2016-08-18 00:07:03 +0800 |
---|---|---|
committer | Denton Liu <liu.denton+github@gmail.com> | 2016-08-18 00:09:20 +0800 |
commit | 1826579f80f7bb7d274765064c4d69f9232f6dd6 (patch) | |
tree | 719c5f0d1a5363ea6d219f905e20c60a80de1404 /docs/control-structures.rst | |
parent | b2507e9f105ab701c417f8f2d125edf8f3022698 (diff) | |
download | dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar.gz dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar.bz2 dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar.lz dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar.xz dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.tar.zst dexon-solidity-1826579f80f7bb7d274765064c4d69f9232f6dd6.zip |
Add documentation about throwing
Diffstat (limited to 'docs/control-structures.rst')
-rw-r--r-- | docs/control-structures.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 5b78d099..ecbf4d12 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -299,11 +299,12 @@ In the following example, we show how ``throw`` can be used to easily revert an } } -Currently, there are three situations, where exceptions happen automatically in Solidity: +Currently, there are four situations, where exceptions happen automatically in Solidity: -1. If you access an array beyond its length (i.e. ``x[i]`` where ``i >= x.length``) +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``). 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. |