@@ -247,7 +247,7 @@ def delete_registry(
247
247
return 'Registry deleted'
248
248
except HttpError :
249
249
print ('Error, registry not deleted' )
250
- return 'Registry not deleted'
250
+ raise
251
251
# [END iot_delete_registry]
252
252
253
253
@@ -391,10 +391,10 @@ def create_registry(
391
391
return response
392
392
except HttpError :
393
393
print ('Error, registry not created' )
394
- return ""
394
+ raise
395
395
except AlreadyExists :
396
396
print ('Error, registry already exists' )
397
- return ""
397
+ raise
398
398
# [END iot_create_registry]
399
399
400
400
@@ -422,12 +422,12 @@ def open_registry(
422
422
# registry_id = 'your-registry-id'
423
423
print ('Creating registry' )
424
424
425
- response = create_registry (
426
- service_account_json , project_id , cloud_region ,
427
- pubsub_topic , registry_id )
428
-
429
- if response == '' :
430
- # Device registry already exists
425
+ try :
426
+ response = create_registry (
427
+ service_account_json , project_id , cloud_region ,
428
+ pubsub_topic , registry_id )
429
+ except AlreadyExists :
430
+ # Device registry already exists. We just re-use the existing one.
431
431
print (
432
432
'Registry {} already exists - looking it up instead.' .format (
433
433
registry_id ))
0 commit comments