aboutsummaryrefslogtreecommitdiffstats
path: root/docs/common-patterns.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-03 22:30:01 +0800
committerchriseth <chris@ethereum.org>2018-04-12 19:09:38 +0800
commit344a388d4461abd7369ea44b123f5afe549dc8f7 (patch)
tree46af2bf9ec5fa6aee5a0fafff3c01a50f79ffd51 /docs/common-patterns.rst
parentaa715f8759934ac68b76a2bef84c460b68be636a (diff)
downloaddexon-solidity-344a388d4461abd7369ea44b123f5afe549dc8f7.tar.gz
dexon-solidity-344a388d4461abd7369ea44b123f5afe549dc8f7.tar.zst
dexon-solidity-344a388d4461abd7369ea44b123f5afe549dc8f7.zip
Update documentation.
Diffstat (limited to 'docs/common-patterns.rst')
-rw-r--r--docs/common-patterns.rst20
1 files changed, 16 insertions, 4 deletions
diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst
index c62b5aca..233bdc4e 100644
--- a/docs/common-patterns.rst
+++ b/docs/common-patterns.rst
@@ -147,7 +147,10 @@ restrictions highly readable.
// a certain address.
modifier onlyBy(address _account)
{
- require(msg.sender == _account);
+ require(
+ msg.sender == _account,
+ "Sender not authorized."
+ );
// Do not forget the "_;"! It will
// be replaced by the actual function
// body when the modifier is used.
@@ -164,7 +167,10 @@ restrictions highly readable.
}
modifier onlyAfter(uint _time) {
- require(now >= _time);
+ require(
+ now >= _time,
+ "Function called too early."
+ );
_;
}
@@ -186,7 +192,10 @@ restrictions highly readable.
// This was dangerous before Solidity version 0.4.0,
// where it was possible to skip the part after `_;`.
modifier costs(uint _amount) {
- require(msg.value >= _amount);
+ require(
+ msg.value >= _amount,
+ "Not enough Ether provided."
+ );
_;
if (msg.value > _amount)
msg.sender.send(msg.value - _amount);
@@ -290,7 +299,10 @@ function finishes.
uint public creationTime = now;
modifier atStage(Stages _stage) {
- require(stage == _stage);
+ require(
+ stage == _stage,
+ "Function cannot be called at this time."
+ );
_;
}