Skip to content

Commit 23cf903

Browse files
authored
catch potential error retrieving datastore results (#2694)
1 parent cd9f9d8 commit 23cf903

File tree

1 file changed

+6
-4
lines changed
  • appengine/flexible/datastore

1 file changed

+6
-4
lines changed

appengine/flexible/datastore/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ def index():
5252
})
5353

5454
ds.put(entity)
55-
5655
query = ds.query(kind='visit', order=('-timestamp',))
5756

58-
results = [
59-
'Time: {timestamp} Addr: {user_ip}'.format(**x)
60-
for x in query.fetch(limit=10)]
57+
results = []
58+
for x in query.fetch(limit=10):
59+
try:
60+
results.append('Time: {timestamp} Addr: {user_ip}'.format(**x))
61+
except KeyError:
62+
print("Error with result format, skipping entry.")
6163

6264
output = 'Last 10 visits:\n{}'.format('\n'.join(results))
6365

0 commit comments

Comments
 (0)