// ReportNonRetryableErrors reports non-retryable errors.
335524
func (m *BatchMethodMetrics) ReportNonRetryableErrors(n int) {
	m.NonRetryableErrors.Inc(int64(n))
	m.Errors.Inc(int64(n))
}
553350
func IsNotRegisteredError(err error) bool {
	if err == nil {
		return false
	}
	_, ok := err.(*notRegisteredErr)
	return ok
}
427234
func NewSerializableError(err error) (*SerializableError, error) {
	// make sure it's one of our errors
	var name string
	switch err.(type) {
	case ErrValidation:
		name = "ErrValidation"
	case ErrBadHierarchy:
		name = "ErrBadHierarchy"
	case ErrBadRoot:
		name = "ErrBadRoot"
	case ErrBadTargets:
		name = "ErrBadTargets"
	case ErrBadSnapshot:
		name = "ErrBadSnapshot"
	default:
		return nil, fmt.Errorf("does not support serializing non-validation errors")
	}
	return &SerializableError{Name: name, Error: err}, nil
}
506471
func IsRetryableAPIError(err error) bool {
	return apierrs.IsTimeout(err) || apierrs.IsServerTimeout(err) || apierrs.IsTooManyRequests(err) || apierrs.IsInternalError(err)
}
1017599
func (r *ReporterSimple) AllKnownErrors() []ReportedError {
	r.lock.RLock()
	defer r.lock.RUnlock()

	if !r.filledOnce {
		// deep copy since r.errors shouldn't be read without the lock.
		errors := make([]ReportedError, r.currErrorIndex+1)
		copy(errors, r.errors[:r.currErrorIndex+1])
		return errors
	}

	errors := make([]ReportedError, r.maxErrors)
	s := r.currErrorIndex + 1
	t := r.maxErrors - s
	copy(errors[:t], r.errors[s:])
	copy(errors[t:], r.errors[:s])
	return errors
}
409389
func (s *localizerPipeline) checkRekeyErrorInner(ctx context.Context, fromErr error, conversationRemote chat1.Conversation, unverifiedTLFName string) (*chat1.ConversationErrorLocal, error) {
	convErrTyp := chat1.ConversationErrorType_TRANSIENT
	var rekeyInfo *chat1.ConversationErrorRekey
	var ok bool

	// check for rekey error type
	if convErrTyp, ok = IsRekeyError(fromErr); !ok {
		return nil, nil
	}
	rekeyInfo = &chat1.ConversationErrorRekey{
		TlfName: unverifiedTLFName,
	}

	if len(conversationRemote.MaxMsgSummaries) == 0 {
		return nil, errors.New("can't determine isPrivate with no maxMsgs")
	}
	rekeyInfo.TlfPublic = conversationRemote.MaxMsgSummaries[0].TlfPublic

	// Fill readers and writers
	parts, err := utils.ReorderParticipants(
		s.G().MetaContext(ctx),
		s.G(),
		s.G().UIDMapper,
		rekeyInfo.TlfName,
		conversationRemote.Metadata.ActiveList)
	if err != nil {
		return nil, err
	}
	var writerNames []string
	for _, p := range parts {
		writerNames = append(writerNames, p.Username)
	}
	rekeyInfo.WriterNames = writerNames

	// Fill rekeyers list
	myUsername := string(s.G().Env.GetUsername())
	rekeyExcludeSelf := (convErrTyp != chat1.ConversationErrorType_SELFREKEYNEEDED)
	for _, w := range writerNames {
		if rekeyExcludeSelf && w == myUsername {
			// Skip self if self can't rekey.
			continue
		}
		if strings.Contains(w, "@") {
			// Skip assertions. They can't rekey.
			continue
		}
		rekeyInfo.Rekeyers = append(rekeyInfo.Rekeyers, w)
	}

	convErrorLocal := chat1.NewConversationErrorLocal(
		fromErr.Error(), conversationRemote, unverifiedTLFName, convErrTyp, rekeyInfo)
	return convErrorLocal, nil
}
164106
func (err MultiError) NilOrError() error {
	if len(err) == 0 {
		return nil
	} else if len(err) == 1 {
		return err[0]
	}
	return err
}
1029089
func RetryAlways(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
	return true, nil
}
1177965
func IsRecordNotFoundError(err error) bool {
	if errs, ok := err.(Errors); ok {
		for _, err := range errs {
			if err == ErrRecordNotFound {
				return true
			}
		}
	}
	return err == ErrRecordNotFound
}
330821
func NewLogarithmicRetryableError(err error, maxAttempts int, baseOffset, scale, power float64) RetryableError {
	return &logarithmicRetryableError{err, maxAttempts, baseOffset, scale, power}
}
161580
func Report(e error, msg string) {
	if e != nil {
		log.Fatalf("Message: (%s) with Error: (%s)", msg, e.Error())
	} else {
		log.Printf("Message: (%s) with NoError", msg)
	}
}
777008
func WrapRetryableError(err error, errorList []*regexp.Regexp, errorCreator ErrorCreator) error {
	if err == nil {
		return nil
	}
	for _, errorRegex := range errorList {
		if errorRegex.MatchString(err.Error()) {
			return errorCreator(err)
		}
	}
	return err
}
1105031
func Report(ctx context.Context, err error) error {
	e := errors.New(ctx, err, 1)
	return reportWithLevel(ctx, DefaultLevel, e)
}
690978
func removeNilErrors(errs []error) []error {
	if len(errs) == 0 {
		return nil
	}
	var r []error
	for _, err := range errs {
		if err != nil {
			r = append(r, err)
		}
	}
	return r
}
1180563
func InnerError(err error) error {
	contained, ok := err.(ContainedError)
	if !ok {
		return nil
	}
	return contained.InnerError()
}
107612
func IsRetryableError(err error) bool {
	if err == nil {
		return false
	}

	if ErrRetryable.Equal(err) ||
		ErrLockConflict.Equal(err) ||
		ErrConditionNotMatch.Equal(err) ||
		// TiKV exception message will tell you if you should retry or not
		strings.Contains(err.Error(), "try again later") {
		return true
	}

	return false
}
759554
func ReportWithLevel(ctx context.Context, level string, err error) error {
	e := errors.New(ctx, err, 1)
	return reportWithLevel(ctx, level, e)
}