// OnError registers a function. Function will be executed if an error
// occurs during the HTTP request.
3566
func (c *Collector) OnError(f ErrorCallback) {
	c.lock.Lock()
	if c.errorCallbacks == nil {
		c.errorCallbacks = make([]ErrorCallback, 0, 4)
	}
	c.errorCallbacks = append(c.errorCallbacks, f)
	c.lock.Unlock()
}
729621
func otherErrorToHTTPError(err error) *httpError {
	var httpErr httpError
	switch err {
	case app.ErrNotFound:
		httpErr.statusCode = http.StatusBadRequest
	case app.ErrExists:
		httpErr.statusCode = http.StatusForbidden
	case app.ErrNoAccess:
		httpErr.statusCode = http.StatusUnauthorized
	default:
		httpErr.statusCode = http.StatusInternalServerError
	}

	httpErr.message = err.Error()
	return &httpErr
}
692173
func (errs Errors) Error() string {
	if len(errs) == 0 {
		return ""
	}
	if len(errs) == 1 {
		return errs[0].Error()
	}

	errors := []string{fmt.Sprint("Multiple errors occurred:")}
	for _, err := range errs {
		errors = append(errors, err.Error())
	}
	return strings.Join(errors, " - ")
}
1086209
func (r *AnalyticsDeferredResultHandle) One(valuePtr interface{}) error {
	if !r.Next(valuePtr) {
		err := r.Close()
		if err != nil {
			return err
		}
		// return ErrNoResults
	}

	// Ignore any errors occurring after we already have our result
	err := r.Close()
	if err != nil {
		// Return no error as we got the one result already.
		return nil
	}

	return nil
}
733700
func (c *Cursor) Err() error {
	if c == nil {
		return errNilCursor
	}

	c.mu.RLock()
	defer c.mu.RUnlock()

	return c.lastErr
}
1321237
func (s *Segmenter) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}
603237
func (is *Is) Err(e error) {
	is.TB.Helper()
	if isNil(e) {
		fail(is, "expected error")
	}
}
90922
func (dec *StreamDecoder) Err() error {
	select {
	case <-dec.done:
		dec.mux.RLock()
		defer dec.mux.RUnlock()
		return dec.err
	default:
		return nil
	}
}
1286822
func ErrorHandler(eh ErrorHandlerFunc) func(*Configuration) error {
	return func(c *Configuration) error {
		c.errorHandler = eh
		return nil
	}
}
548520
func errHandler(err error) handlerFunc {
	return func(w http.ResponseWriter, r *http.Request) error {
		return err
	}
}
97350
func (he *HttpError) Error() string {
	return fmt.Sprintf("http status code: %d while fetching url %s",
		he.StatusCode, he.Url)
}
923506
func (t *Tomb) Err() (reason error) {
	t.init()
	t.m.Lock()
	reason = t.reason
	t.m.Unlock()
	return
}
870145
func (l *List) Err() error {
	if len(l.errs) == 0 {
		return nil
	}

	if l.err != nil {
		switch len(l.errs) {
		case 1:
			l.err = l.errs[0]

		default:
			var sb strings.Builder
			sb.WriteString(l.errs[0].Error())
			for _, err := range l.errs[1:] {
				sb.WriteRune('\n')
				sb.WriteString(err.Error())
			}
			l.err = errors.New(sb.String())
		}
	}

	return l.err
}
310052
func (c Context) Err(err error) Context {
	return c.AnErr(ErrorFieldName, err)
}
295124
func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int) {
	if logMsg != "" {
		log.Println(logMsg)
	}

	http.Error(w, err, errCode)
}
1003487
func (t *Throttler) Err() error {
	t.errsMutex.Lock()
	defer t.errsMutex.Unlock()
	if atomic.LoadInt32(&t.errorCount) == 0 {
		return nil
	}
	return multiError(t.errs)
}
959682
func ErrorHandler(cb ErrHandler) Option {
	return func(o *Options) error {
		o.AsyncErrorCB = cb
		return nil
	}
}