Restrict exception to IndexError as @Galithil suggested