Checks that a response is successful, raising the appropriate Exceptions otherwise.

def check_response(response):
    """ Checks that a response is successful, raising the appropriate Exceptions otherwise. """
    status_code = response.status_code

    if 100 < status_code < 299:
        return True

    elif status_code == 401 or status_code == 403:
        message = get_response_data(response)
        raise AuthError('Access Token Error, Received ' + str(status_code) +
                        ' from Outlook REST Endpoint with the message: {}'.format(message))

    elif status_code == 400:
        message = get_response_data(response)
        raise RequestError('The request made to the Outlook API was invalid. Received the following message: {}'.
                           format(message))
    else:
        message = get_response_data(response)
        raise APIError('Encountered an unknown error from the Outlook API: {}'.format(message))