code: def try_write(wd_item, record_id, record_prop, login, edit_summary='', write=True):
      
      if wd_item.require_write:
          if wd_item.create_new_item:
              msg = "CREATE"
          else:
              msg = "UPDATE"
      else:
          msg = "SKIP"
  
      try:
          if write:
              wd_item.write(login=login, edit_summary=edit_summary)
          wdi_core.WDItemEngine.log("INFO", format_msg(record_id, record_prop, wd_item.wd_item_id, msg) + ";" + str(
              wd_item.lastrevid))
      except wdi_core.WDApiError as e:
          print(e)
          wdi_core.WDItemEngine.log("ERROR",
                                    format_msg(record_id, record_prop, wd_item.wd_item_id, json.dumps(e.wd_error_msg),
                                               type(e)))
          return e
      except Exception as e:
          print(e)
          wdi_core.WDItemEngine.log("ERROR", format_msg(record_id, record_prop, wd_item.wd_item_id, str(e), type(e)))
          return e
  
      return True
docs: Write a PBB_core item. Log if item was created, updated, or skipped.
      Catch and log all errors.
  
      :param wd_item: A wikidata item that will be written
      :type wd_item: PBB_Core.WDItemEngine
      :param record_id: An external identifier, to be used for logging
      :type record_id: str
      :param record_prop: Property of the external identifier
      :type record_prop: str
      :param login: PBB_core login instance
      :type login: PBB_login.WDLogin
      :param edit_summary: passed directly to wd_item.write
      :type edit_summary: str
      :param write: If `False`, do not actually perform write. Action will be logged as if write had occured
      :type write: bool
      :return: True if write did not throw an exception, returns the exception otherwise