Question about the dereferenced nil pointer in client.go

there is a line 1564 in client.go
https://github.com/hashicorp/vault/blob/main/api/client.go#L1564

    if result != nil {
		for _, cb := range c.responseCallbacks {
			cb(result)
		}

		if c.config.ReadYourWrites {
			c.replicationStateStore.recordState(result)
		}
	}
	if err := result.Error(); err != nil {
		return result, err
	}

so if result == nil, than err := result.Error() will cause a panic.
however, there is a code above

	var result *Response
	resp, err := client.Do(req)
	if resp != nil {
		result = &Response{Response: resp}
	}
	if err != nil {
		if strings.Contains(err.Error(), "tls: oversized") {
			err = errwrap.Wrapf("{{err}}\n\n"+TLSErrorString, err)
		}
		return result, err
	}

There may be several options here:

  1. resp==nil and err != nil
  2. resp!=nil and err == nil
  3. resp==nil and err == nil: There can be no such option.

So, if result == nil, we will return before error line
why do we need to do this check?
or, if we do this check, why don’t we check the error: result.Error()?