Skip to content

Commit 16cb806

Browse files
caberoscaberos
authored andcommitted
slcli hw add-notifications crashes with a bad user
1 parent 373a53a commit 16cb806

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

SoftLayer/CLI/hardware/add_notification.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
89
from SoftLayer.CLI import formatting
910

1011

@@ -23,9 +24,13 @@ def cli(env, identifier, users):
2324
table.align['Username'] = 'l'
2425

2526
for user in users:
26-
notification = hardware.add_notification(identifier, user)
27-
table.add_row([notification['id'], notification['hardware']['fullyQualifiedDomainName'],
28-
notification['user']['username'], notification['user']['email'],
29-
notification['user']['firstName'], notification['user']['lastName']])
30-
27+
try:
28+
notification = hardware.add_notification(identifier, user)
29+
print(notification)
30+
table.add_row([notification['id'], notification['hardware']['fullyQualifiedDomainName'],
31+
notification['user']['username'], notification['user']['email'],
32+
notification['user']['firstName'], notification['user']['lastName']])
33+
34+
except Exception:
35+
raise exceptions.CLIAbort("User not found: {}.".format(user))
3136
env.fout(table)

0 commit comments

Comments
 (0)