Skip to content

Exception handling if empty#2

Open
Shinerrs wants to merge 1 commit into
bwood:masterfrom
Shinerrs:master
Open

Exception handling if empty#2
Shinerrs wants to merge 1 commit into
bwood:masterfrom
Shinerrs:master

Conversation

@Shinerrs

Copy link
Copy Markdown

This works for me locally. I pulled and changed Owners=['amazon'] to my ownerid and it returned an empty list.

This caused the following error:

[mash@localhost latest-ami]$ python latest-ami.py eu-central-1 
[]
Traceback (most recent call last):
  File "latest-ami.py", line 34, in <module>
    print(source_image['ImageId'])
TypeError: 'NoneType' object has no attribute '__getitem__'

So I added a if check, if the list is populated then source_image, otherwise, trow message and end cleanly.

@Shinerrs Shinerrs mentioned this pull request Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant