Skip to content

Commit d2638cc

Browse files
committed
Merge pull request #163 from kawasakitoshiya/add_doc_about_error
add explanation about read error
2 parents 350d810 + 3a932de commit d2638cc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ Read a key
6767
client.read('/nodes', recursive = True) #get all the values of a directory, recursively.
6868
client.get('/nodes/n2').value
6969
70+
# raises etcd.EtcdKeyNotFound when key not found
71+
try:
72+
client.read('/invalid/path')
73+
except etcd.EtcdKeyNotFound:
74+
# do something
75+
print "error"
76+
77+
7078
Delete a key
7179
~~~~~~~~~~~~
7280

docs-source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ Get a key
8888
client.read('/nodes/n2', wait=True) #Waits for a change in value in the key before returning.
8989
client.read('/nodes/n2', wait=True, waitIndex=10)
9090
91+
# raises etcd.EtcdKeyNotFound when key not found
92+
try:
93+
client.read('/invalid/path')
94+
except etcd.EtcdKeyNotFound:
95+
# do something
96+
print "error"
9197
9298
9399
Delete a key

0 commit comments

Comments
 (0)