With code like the snippet below, we can catch AWS exceptions:
from aws_utils import make_session session = make_session() cf = session.resource(\"iam\") ro
try: something except client.exceptions.NoSuchEntityException: something
This worked for me