def _check_api_rate_exceeded(r, exit_loop=False):
    """
    Internal function for catching api exceeded error.

    Parameters
    ----------
    r: dict
        response.json() returned from the Petfinder API.

    Returns
    -------
    None
        raises an error and terminates the program

    """
    if isinstance(r, dict):
        if 'status' in r.keys() and r['status'] == 429:
            if exit_loop:
                print(r['title'])
                return True
            else:
                raise RuntimeError(r['title'])
