code: def handle_wikidata_errors(data, query):
      
      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)
docs: Raises LookupError if wikidata error found