Skip to content

Commit

Permalink
feat(infra.py): Add try except block for get_datastore. fix #433 @0.5h
Browse files Browse the repository at this point in the history
  • Loading branch information
hayatedayon committed Sep 29, 2018
1 parent 8fd2ac9 commit 74968ec
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from google.appengine.ext import ndb

import json
import logging
import random

# しりとりが WORDS_COUNT_LIMIT 以上続いたら AI が降参する
Expand Down Expand Up @@ -67,13 +68,16 @@ def reset_datastore(user):


def get_datastore(user_id):
user = User.get_by_id(user_id)
if user:
obj = {u'words': user.words,
u'last_word': user.last_word,
u'count': user.count,
}
return obj
try:
user = User.get_by_id(user_id)
if user:
obj = {u'words': user.words,
u'last_word': user.last_word,
u'count': user.count,
}
return obj
except Exception as e:
logging.exception(u'get_datasore: %s', e)
return {}


Expand Down

0 comments on commit 74968ec

Please sign in to comment.