latest-ami icon indicating copy to clipboard operation
latest-ami copied to clipboard

Exception handling if empty

Open Shinerrs opened this issue 6 years ago • 0 comments

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 avatar Aug 15 '18 15:08 Shinerrs