code: func checkResponse(req *http.Request, res *http.Response, ignoreErrors ...int) error {
  	// 200-299 are valid status codes
  	if res.StatusCode >= 200 && res.StatusCode <= 299 {
  		return nil
  	}
  	// Ignore certain errors?
  	for _, code := range ignoreErrors {
  		if code == res.StatusCode {
  			return nil
  		}
  	}
  	return createResponseError(res)
  }
docs: // checkResponse will return an error if the request/response indicates
  // an error returned from Elasticsearch.
  //
  // HTTP status codes between in the range [200..299] are considered successful.
  // All other errors are considered errors except they are specified in
  // ignoreErrors. This is necessary because for some services, HTTP status 404
  // is a valid response from Elasticsearch (e.g. the Exists service).
  //
  // The func tries to parse error details as returned from Elasticsearch
  // and encapsulates them in type elastic.Error.