def handle_wikidata_errors(data, query):
    """
    Raises LookupError if wikidata error found
    """
    entities = data.get('entities')

    if not entities:
        raise LookupError(query)
    elif '-1' in entities:
        raise LookupError(query)
    else:
        item = list(entities.values())[0]
        if 'missing' in item:
            errmsg = "wikidata item %s has been deleted" % item['id']
            raise LookupError(errmsg)
Raises LookupError if wikidata error found