// try is used to encapsulate a HTTP operation and retrieve the optional
// nimbusec error if one happened.
493035
func try(resp *http.Response, err error) (*http.Response, error) {
	if resp == nil {
		return resp, err
	}

	if resp.StatusCode < 300 {
		return resp, err
	}

	msg := resp.Header.Get("x-nimbusec-error")
	if msg != "" {
		return resp, errors.New(msg)
	}

	return resp, err
}
904088
func (err *ErrSession) Error() string {
	if err.Err == nil {
		return fmt.Sprintf("%s (%s)", stateTexts[err.State], err.Type)
	}
	return fmt.Sprintf("%s: %s (%s)", stateTexts[err.State], err.Err, err.Type)
}
774700
func (e *ErrInvalidEnv) Error() string {
	return fmt.Sprintf("utils: %q is an invalid env: %q", e.Env, e.Msg)
}
1069827
func (e BadRequestError) Error() string {
	return fmt.Sprintf("bad request: %s", e.err.(network.UnexpectedStatusError).Body)
}
334651
func (r *Response) Error() string {
	if r.ResponseError != nil {
		return r.ResponseError.Error()
	}
	return ""
}
449709
func Error(w http.ResponseWriter, code int, fmtStr string, vars ...interface{}) {
	http.Error(w, fmt.Sprintf(fmtStr, vars...), code)
}
910353
func (a *AddrManager) Attempt(addr *wire.NetAddress) {
	a.mtx.Lock()
	defer a.mtx.Unlock()

	// find address.
	// Surely address will be in tried by now?
	ka := a.find(addr)
	if ka == nil {
		return
	}
	// set last tried time to now
	ka.attempts++
	ka.lastattempt = time.Now()
}
1336091
func (t *migrateWorker) try(info *resource.Info, retries int) (attemptResult, error) {
	reporter, err := t.migrateFn(info)
	if err != nil {
		return attemptResultError, err
	}
	if reporter == nil {
		return attemptResultIgnore, nil
	}
	if !reporter.Changed() {
		return attemptResultUnchanged, nil
	}
	if t.actionFn != nil {
		if err := t.actionFn(info, reporter); err != nil {
			if err == ErrUnchanged {
				return attemptResultUnchanged, nil
			}
			if canRetry(err) {
				if retries > 0 {
					if bool(klog.V(1)) && err != ErrRecalculate {
						// signal that we had to retry on this resource
						t.results <- resultData{retry: true, data: workData{info: info, err: err}}
					}
					result, err := t.try(info, retries-1)
					switch result {
					case attemptResultUnchanged, attemptResultIgnore:
						result = attemptResultSuccess
					}
					return result, err
				}
			}
			return attemptResultError, err
		}
	}
	return attemptResultSuccess, nil
}
594092
func (e ErrorResponse) Error() string {
	return fmt.Sprintf("API error %s %d (%s %d): %s", e.ErrorCode, e.ErrorCode, e.CSErrorCode, e.CSErrorCode, e.ErrorText)
}
1181971
func (this Error) Error() string {
	return fmt.Sprintf("httpclient #%d: %s", this.Code, this.Message)
}
874734
func (c *Client) get(url string) (string, error) {
	resp, err := http.Get(url)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	todo := new(Todo)
	if err = json.NewDecoder(resp.Body).Decode(todo); err != nil {
		return "", err
	}
	return todo.Task, nil
}
1000135
func (r *RateLimiter) Try() (ok bool, remaining time.Duration) {
	r.mtx.Lock()
	defer r.mtx.Unlock()
	now := time.Now()
	if l := r.times.Len(); l < r.limit {
		r.times.PushBack(now)
		return true, 0
	}
	frnt := r.times.Front()
	if diff := now.Sub(frnt.Value.(time.Time)); diff < r.interval {
		return false, r.interval - diff
	}
	frnt.Value = now
	r.times.MoveToBack(frnt)
	return true, 0
}
57960
func (t *Thread) Try(f func(t *Thread)) error {
	oc := t.abort
	c := make(chan error)
	t.abort = c
	go func() {
		f(t)
		c <- nil
	}()
	err := <-c
	t.abort = oc
	return err
}
97350
func (he *HttpError) Error() string {
	return fmt.Sprintf("http status code: %d while fetching url %s",
		he.StatusCode, he.Url)
}
1171799
func (e *ErrorResponse) Error() string {
	if e.Message == "" {
		e.Message = "Request error"
	}

	return fmt.Sprintf(
		"%d %s",
		e.Response.StatusCode,
		e.Message,
	)
}
422
func (apigError *Error) Error() string {
	bytes, bytesErr := json.Marshal(apigError)
	if bytesErr != nil {
		bytes = []byte(http.StatusText(http.StatusInternalServerError))
	}
	return string(bytes)
}
29643
func (v *Error) Error() string {
	return fmt.Sprintf("%s: %s", v.Field, v.ErrorBody())
}