Skip to content

Commit

Permalink
Fail with message if no suitable image available
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Jul 2, 2021
1 parent 803f3ea commit 9d1e91f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mkimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def get_cover_image(image_path):
ratio = calculate_ratio(tmp_image)
if ratio < 1:
candidates.remove(image)
chosen_image = random.choice(candidates)
try:
chosen_image = random.choice(candidates)
except IndexError:
logging.error("No suitable image found. Exiting.")
sys.exit()

return chosen_image
# def get_cover_image ends here

Expand Down

0 comments on commit 9d1e91f

Please sign in to comment.