// GetEncodedErrors gets the list of encoded errors in a format suitable
// for error file.
962226
func GetEncodedErrors(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) {
	return func(_ context.Context) ([]byte, time.Time, error) {
		errors := config.Reporter().AllKnownErrors()
		jsonErrors := make([]JSONReportedError, len(errors))
		for i, e := range errors {
			jsonErrors[i].Time = e.Time
			jsonErrors[i].Error = e.Error.Error()
			jsonErrors[i].Stack = convertStack(e.Stack)
		}
		data, err := PrettyJSON(jsonErrors)
		var t time.Time
		if len(errors) > 0 {
			t = errors[len(errors)-1].Time
		}
		return data, t, err
	}
}
369877
func (aer *AllErrorRecorder) GetErrors() []error {
	aer.mu.Lock()
	defer aer.mu.Unlock()
	return aer.Errors
}
649267
func (e ErrEncodeLease) Error() string {
	return fmt.Sprintf("error encoding lease for cluster %s (%s)", e.l.ClusterName, e.encodeErr)
}
304015
func (m MultiError) Error() string {
	msgs := make([]string, len(m))
	for i, de := range m {
		msgs[i] = de.Error()
	}
	return strings.Join(msgs, "\n")
}
716874
func ResponseHeadersEncodeError(req *transport.Request, err error) error {
	return newServerEncodingError(req, nil, true /*isResponse*/, true /*isHeader*/, err)
}
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
}
467578
func RemoveNilErrors(errs []error) []error {
	var r []error
	for _, err := range errs {
		if err != nil {
			r = append(r, err)
		}
	}
	return r
}
605352
func GetErrorCodeGroup(name string) []ErrorDescriptor {
	desc := groupToDescriptors[name]
	sort.Sort(byValue(desc))
	return desc
}
658758
func (errs *Errors) AddError(errors ...error) {
	for _, err := range errors {
		if err != nil {
			if e, ok := err.(errorsInterface); ok {
				errs.errors = append(errs.errors, e.GetErrors()...)
			} else {
				errs.errors = append(errs.errors, err)
			}
		}
	}
}
695778
func DefaultErrorEncoder(ctx context.Context, err error) ([]byte, error) {
	return nil, err
}
162272
func GetExits(err error) string {
	if err == nil {
		return ""
	}
	cast, ok := err.(*Error)
	if !ok {
		return ""
	}
	return cast.Exits()
}
1244941
func getErrors(ctx *macaron.Context) Errors {
	return ctx.GetVal(reflect.TypeOf(Errors{})).Interface().(Errors)
}
677965
func (e *Error) WrappedErrors() []error {
	if e == nil {
		return nil
	}

	result := make([]error, len(e.Errors))
	for i, e := range e.Errors {
		result[i] = errors.New(e)
	}

	return result
}
1210227
func (b *Blob) GetEncoding() string {
	if b == nil || b.Encoding == nil {
		return ""
	}
	return *b.Encoding
}
122333
func (v *ValidationMessages) getWarnings() error {
	var messages []string
	for _, msg := range v.Messages {
		if msg.Typ == WARN || msg.Typ == CRIT {
			messages = append(messages, msg.Message)
		}
	}
	if len(messages) > 0 {
		return fmt.Errorf("Validation failed: %s", strings.Join(messages, ","))
	}
	return nil
}
156972
func FindError(err error, code Code) Code {
	if err == nil {
		return NonError
	}

	if merr, ok := err.(*multierror.Error); ok {
		if merr.ErrorOrNil() == nil {
			return NonError
		}
		for _, e := range merr.Errors {
			if rfcErr, ok := e.(*Error); ok {
				if rfcErr.Code == code {
					return code
				}
			}
		}
	}
	return NonRFCError
}
1242389
func getMemifError(code int) error {
	if code == 0 {
		return nil /* success */
	}
	err, known := errorRegistry[code]
	if !known {
		return ErrUnknown
	}
	return err
}