code: def _check_write_command_response(result):
      
      # Prefer write errors over write concern errors
      write_errors = result.get("writeErrors")
      if write_errors:
          _raise_last_write_error(write_errors)
  
      error = result.get("writeConcernError")
      if error:
          _raise_write_concern_error(error)
docs: Backward compatibility helper for write command error handling.