// NewSerializableError serializes one of the above errors into JSON
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
}
335524
func (m *BatchMethodMetrics) ReportNonRetryableErrors(n int) {
	m.NonRetryableErrors.Inc(int64(n))
	m.Errors.Inc(int64(n))
}
966611
func structOnlyError(t reflect.Type) error {
	isStruct := t.Kind() == reflect.Struct
	isScanner := reflect.PtrTo(t).Implements(_unmarshallerInterface)
	if !isStruct {
		return fmt.Errorf("expected %s but got %s", reflect.Struct, t.Kind())
	}
	if isScanner {
		return fmt.Errorf("structscan expects a struct dest but the provided struct type %s implements unmarshaler", t.Name())
	}
	return fmt.Errorf("expected a struct, but struct %s has no exported fields", t.Name())
}
895430
func NewServerTimeout(qualifiedResource schema.GroupResource, operation string, retryAfterSeconds int) *StatusError {
	return &StatusError{metav1.Status{
		Status: metav1.StatusFailure,
		Code:   http.StatusInternalServerError,
		Reason: metav1.StatusReasonServerTimeout,
		Details: &metav1.StatusDetails{
			Group:             qualifiedResource.Group,
			Kind:              qualifiedResource.Resource,
			Name:              operation,
			RetryAfterSeconds: int32(retryAfterSeconds),
		},
		Message: fmt.Sprintf("The %s operation against %s could not be completed at this time, please try again.", operation, qualifiedResource.String()),
	}}
}
1220186
func recoverablePullError(err error, image string) error {
	recoverable := true
	if imageNotFoundMatcher.MatchString(err.Error()) {
		recoverable = false
	}
	return structs.NewRecoverableError(fmt.Errorf("Failed to pull `%s`: %s", image, err), recoverable)
}
732778
func IsErrorRetryable(err error) bool {
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			return isCodeRetryable(aerr.Code()) || isNestedErrorRetryable(aerr)
		}
	}
	return false
}
1304051
func (ctx *Context) JSONError(v interface{}) error {
	ctx.Err500()
	return ctx.JSON(v)
}
900506
func NewServeMux(sendErrorCallback func(ResponseWriter, *http.Request, error), errorContentType string, recoverPanic bool, logger *log.Logger) *ServeMux {
	if logger == nil {
		logger = log.New(os.Stderr, "", log.LstdFlags)
	}
	if sendErrorCallback == nil {
		sendErrorCallback = func(w ResponseWriter, req *http.Request, err error) {
			fmt.Fprintf(w, "%s\n", err)
		}
	}
	return &ServeMux{
		ServeMux:         http.NewServeMux(),
		sendError:        sendErrorCallback,
		errorContentType: errorContentType,
		recoverPanic:     recoverPanic,
		log:              logger,
	}
}
1349459
func GetInnerRetryableError(err error) error {
	for err != nil {
		if _, ok := err.(retryableError); ok {
			return InnerError(err)
		}
		err = InnerError(err)
	}
	return nil
}
179484
func NewSetCustomObjectFormatterEnabledArgs(enabled bool) *SetCustomObjectFormatterEnabledArgs {
	args := new(SetCustomObjectFormatterEnabledArgs)
	args.Enabled = enabled
	return args
}
863293
func (m *marshalableError) MarshalJSON() ([]byte, error) {
	return json.Marshal(m.err.Error())
}
294125
func NewServiceUnavailable(reason string) *StatusError {
	return &StatusError{metav1.Status{
		Status:  metav1.StatusFailure,
		Code:    http.StatusServiceUnavailable,
		Reason:  metav1.StatusReasonServiceUnavailable,
		Message: reason,
	}}
}
287975
func GetErrorPayload(serializer serialize.Serializer, err error) ([]byte, error) {
	code := e.ErrUnknownCode
	msg := err.Error()
	metadata := map[string]string{}
	if val, ok := err.(*e.Error); ok {
		code = val.Code
		metadata = val.Metadata
	}
	errPayload := &protos.Error{
		Code: code,
		Msg:  msg,
	}
	if len(metadata) > 0 {
		errPayload.Metadata = metadata
	}
	return SerializeOrRaw(serializer, errPayload)
}
452652
func NewSharedStringRefTable() *RefTable {
	rt := RefTable{}
	rt.knownStrings = make(map[string]int)
	return &rt
}
108559
func jsonError(err error) string {
	var errMsg struct {
		Err string `json:"err"`
	}
	errMsg.Err = err.Error()

	data, _ := json.Marshal(&errMsg)
	return string(data)
}
770211
func NewSetIgnoreCertificateErrorsArgs(ignore bool) *SetIgnoreCertificateErrorsArgs {
	args := new(SetIgnoreCertificateErrorsArgs)
	args.Ignore = ignore
	return args
}
692585
func NewStatErrorResponse(
	err error,
	entries map[int](map[string]string)) StatResponse {
	return &genericResponse{
		err:         err,
		statEntries: entries,
	}
}