Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 620cd20

Browse files
committed
google-assistant-sdk: surface proper permission error
When GetModel fails with 403, let CreateModel fails to bubble up the proper error message. Bug: 69180554 Change-Id: I84a76d46b95a59c484b0ee02e6d700d166baf431
1 parent 3e9e824 commit 620cd20

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

google-assistant-sdk/googlesamples/assistant/grpc/devicetool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,12 @@ def register_model(ctx, model, type, trait,
241241
if r.status_code == 200:
242242
click.echo('Updating existing device model: %s' % model)
243243
r = session.put(model_url, data=json.dumps(payload))
244-
elif r.status_code in (400, 404):
244+
elif r.status_code in (400, 403, 404):
245245
click.echo('Creating new device model')
246246
r = session.post(model_base_url, data=json.dumps(payload))
247247
else:
248-
raise failed_request_exception('Unknown error occurred', r)
248+
raise failed_request_exception('Failed to check existing device model',
249+
r)
249250
if r.status_code != 200:
250251
raise failed_request_exception('Failed to register model', r)
251252
click.echo('Model %s successfully registered' % model)
@@ -296,7 +297,7 @@ def register_device(ctx, device, model, nickname, client_type):
296297
click.echo('Updating existing device: %s' % device)
297298
session.delete(device_url)
298299
r = session.post(device_base_url, data=json.dumps(payload))
299-
elif r.status_code in (400, 404):
300+
elif r.status_code in (400, 403, 404):
300301
click.echo('Creating new device')
301302
r = session.post(device_base_url, data=json.dumps(payload))
302303
else:

0 commit comments

Comments
 (0)