def get_error_messages( response ):
    """
    Builds a string based on the error messages in the payload

    Args:
        response: The response to print

    Returns:
        The string containing error messages
    """

    # Pull out the error payload and the messages
    out_string = response.dict["error"]["message"]
    if "@Message.ExtendedInfo" in response.dict["error"]:
        for message in response.dict["error"]["@Message.ExtendedInfo"]:
            if "Message" in message:
                out_string = out_string + "\n" + message["Message"]
            else:
                out_string = out_string + "\n" + message["MessageId"]

    return out_string