diff --git a/firestore/cloud-client/snippets.py b/firestore/cloud-client/snippets.py index ef06fbe1002..f40766c476d 100644 --- a/firestore/cloud-client/snippets.py +++ b/firestore/cloud-client/snippets.py @@ -15,7 +15,6 @@ from time import sleep from google.cloud import firestore -import google.cloud.exceptions def quickstart_new_instance(): @@ -217,10 +216,10 @@ def get_check_exists(): # [START get_check_exists] doc_ref = db.collection(u'cities').document(u'SF') - try: - doc = doc_ref.get() + doc = doc_ref.get() + if doc.exists: print(u'Document data: {}'.format(doc.to_dict())) - except google.cloud.exceptions.NotFound: + else: print(u'No such document!') # [END get_check_exists]