code: func getError(r *http.Response, req *http.Request) error {
  	if c := r.StatusCode; 200 <= c && c <= 299 {
  		return nil
  	}
  
  	errorResponse := &ErrorResponse{Response: r}
  	data, err := ioutil.ReadAll(r.Body)
  	if err == nil && data != nil {
  		json.Unmarshal(data, errorResponse)
  	}
  	errorResponse.Status = r.Status
  	errorResponse.StatusCode = r.StatusCode
  	errorResponse.Request = req
  
  	switch r.StatusCode {
  	case http.StatusBadRequest:
  		return &ErrBadRequest{ErrorResponse: errorResponse}
  	case http.StatusUnauthorized:
  		return &ErrUnauthorized{ErrorResponse: errorResponse}
  	case http.StatusServiceUnavailable:
  		return &ErrTemporarilyUnavailable{ErrorResponse: errorResponse}
  	case http.StatusNotFound:
  		return &ErrNotFound{ErrorResponse: errorResponse}
  	case http.StatusGone:
  		return &ErrDeleted{ErrorResponse: errorResponse}
  	default:
  		return &ErrUnexpected{ErrorResponse: errorResponse}
  	}
  }
docs: // getError inspects the HTTP response and constructs an appropriate error if
  // the response was an error.