type StatusError … type APIStatus … var _ … var knownReasons … // Error implements the Error interface. func (e *StatusError) Error() string { … } // Status allows access to e's status without having to know the detailed workings // of StatusError. func (e *StatusError) Status() metav1.Status { … } // DebugError reports extended info about the error to debug output. func (e *StatusError) DebugError() (string, []interface{ … } // HasStatusCause returns true if the provided error has a details cause // with the provided type name. // It supports wrapped errors and returns false when the error is nil. func HasStatusCause(err error, name metav1.CauseType) bool { … } // StatusCause returns the named cause from the provided error if it exists and // the error unwraps to the type APIStatus. Otherwise it returns false. func StatusCause(err error, name metav1.CauseType) (metav1.StatusCause, bool) { … } type UnexpectedObjectError … // Error returns an error message describing 'u'. func (u *UnexpectedObjectError) Error() string { … } // FromObject generates an StatusError from an metav1.Status, if that is the type of obj; otherwise, // returns an UnexpecteObjectError. func FromObject(obj runtime.Object) error { … } // NewNotFound returns a new error which indicates that the resource of the kind and the name was not found. func NewNotFound(qualifiedResource schema.GroupResource, name string) *StatusError { … } // NewAlreadyExists returns an error indicating the item requested exists by that identifier. func NewAlreadyExists(qualifiedResource schema.GroupResource, name string) *StatusError { … } // NewGenerateNameConflict returns an error indicating the server // was not able to generate a valid name for a resource. func NewGenerateNameConflict(qualifiedResource schema.GroupResource, name string, retryAfterSeconds int) *StatusError { … } // NewUnauthorized returns an error indicating the client is not authorized to perform the requested // action. func NewUnauthorized(reason string) *StatusError { … } // NewForbidden returns an error indicating the requested action was forbidden func NewForbidden(qualifiedResource schema.GroupResource, name string, err error) *StatusError { … } // NewConflict returns an error indicating the item can't be updated as provided. func NewConflict(qualifiedResource schema.GroupResource, name string, err error) *StatusError { … } // NewApplyConflict returns an error including details on the requests apply conflicts func NewApplyConflict(causes []metav1.StatusCause, message string) *StatusError { … } // NewGone returns an error indicating the item no longer available at the server and no forwarding address is known. // DEPRECATED: Please use NewResourceExpired instead. func NewGone(message string) *StatusError { … } // NewResourceExpired creates an error that indicates that the requested resource content has expired from // the server (usually due to a resourceVersion that is too old). func NewResourceExpired(message string) *StatusError { … } // NewInvalid returns an error indicating the item is invalid and cannot be processed. func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorList) *StatusError { … } // NewBadRequest creates an error that indicates that the request is invalid and can not be processed. func NewBadRequest(reason string) *StatusError { … } // NewTooManyRequests creates an error that indicates that the client must try again later because // the specified endpoint is not accepting requests. More specific details should be provided // if client should know why the failure was limited. func NewTooManyRequests(message string, retryAfterSeconds int) *StatusError { … } // NewServiceUnavailable creates an error that indicates that the requested service is unavailable. func NewServiceUnavailable(reason string) *StatusError { … } // NewMethodNotSupported returns an error indicating the requested action is not supported on this kind. func NewMethodNotSupported(qualifiedResource schema.GroupResource, action string) *StatusError { … } // NewServerTimeout returns an error indicating the requested action could not be completed due to a // transient error, and the client should try again. func NewServerTimeout(qualifiedResource schema.GroupResource, operation string, retryAfterSeconds int) *StatusError { … } // NewServerTimeoutForKind should not exist. Server timeouts happen when accessing resources, the Kind is just what we // happened to be looking at when the request failed. This delegates to keep code sane, but we should work towards removing this. func NewServerTimeoutForKind(qualifiedKind schema.GroupKind, operation string, retryAfterSeconds int) *StatusError { … } // NewInternalError returns an error indicating the item is invalid and cannot be processed. func NewInternalError(err error) *StatusError { … } // NewTimeoutError returns an error indicating that a timeout occurred before the request // could be completed. Clients may retry, but the operation may still complete. func NewTimeoutError(message string, retryAfterSeconds int) *StatusError { … } // NewTooManyRequestsError returns an error indicating that the request was rejected because // the server has received too many requests. Client should wait and retry. But if the request // is perishable, then the client should not retry the request. func NewTooManyRequestsError(message string) *StatusError { … } // NewRequestEntityTooLargeError returns an error indicating that the request // entity was too large. func NewRequestEntityTooLargeError(message string) *StatusError { … } // NewGenericServerResponse returns a new error for server responses that are not in a recognizable form. func NewGenericServerResponse(code int, verb string, qualifiedResource schema.GroupResource, name, serverMessage string, retryAfterSeconds int, isUnexpectedResponse bool) *StatusError { … } // IsNotFound returns true if the specified error was created by NewNotFound. // It supports wrapped errors and returns false when the error is nil. func IsNotFound(err error) bool { … } // IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists. // It supports wrapped errors and returns false when the error is nil. func IsAlreadyExists(err error) bool { … } // IsConflict determines if the err is an error which indicates the provided update conflicts. // It supports wrapped errors and returns false when the error is nil. func IsConflict(err error) bool { … } // IsInvalid determines if the err is an error which indicates the provided resource is not valid. // It supports wrapped errors and returns false when the error is nil. func IsInvalid(err error) bool { … } // IsGone is true if the error indicates the requested resource is no longer available. // It supports wrapped errors and returns false when the error is nil. func IsGone(err error) bool { … } // IsResourceExpired is true if the error indicates the resource has expired and the current action is // no longer possible. // It supports wrapped errors and returns false when the error is nil. func IsResourceExpired(err error) bool { … } // IsNotAcceptable determines if err is an error which indicates that the request failed due to an invalid Accept header // It supports wrapped errors and returns false when the error is nil. func IsNotAcceptable(err error) bool { … } // IsUnsupportedMediaType determines if err is an error which indicates that the request failed due to an invalid Content-Type header // It supports wrapped errors and returns false when the error is nil. func IsUnsupportedMediaType(err error) bool { … } // IsMethodNotSupported determines if the err is an error which indicates the provided action could not // be performed because it is not supported by the server. // It supports wrapped errors and returns false when the error is nil. func IsMethodNotSupported(err error) bool { … } // IsServiceUnavailable is true if the error indicates the underlying service is no longer available. // It supports wrapped errors and returns false when the error is nil. func IsServiceUnavailable(err error) bool { … } // IsBadRequest determines if err is an error which indicates that the request is invalid. // It supports wrapped errors and returns false when the error is nil. func IsBadRequest(err error) bool { … } // IsUnauthorized determines if err is an error which indicates that the request is unauthorized and // requires authentication by the user. // It supports wrapped errors and returns false when the error is nil. func IsUnauthorized(err error) bool { … } // IsForbidden determines if err is an error which indicates that the request is forbidden and cannot // be completed as requested. // It supports wrapped errors and returns false when the error is nil. func IsForbidden(err error) bool { … } // IsTimeout determines if err is an error which indicates that request times out due to long // processing. // It supports wrapped errors and returns false when the error is nil. func IsTimeout(err error) bool { … } // IsServerTimeout determines if err is an error which indicates that the request needs to be retried // by the client. // It supports wrapped errors and returns false when the error is nil. func IsServerTimeout(err error) bool { … } // IsInternalError determines if err is an error which indicates an internal server error. // It supports wrapped errors and returns false when the error is nil. func IsInternalError(err error) bool { … } // IsTooManyRequests determines if err is an error which indicates that there are too many requests // that the server cannot handle. // It supports wrapped errors and returns false when the error is nil. func IsTooManyRequests(err error) bool { … } // IsRequestEntityTooLargeError determines if err is an error which indicates // the request entity is too large. // It supports wrapped errors and returns false when the error is nil. func IsRequestEntityTooLargeError(err error) bool { … } // IsUnexpectedServerError returns true if the server response was not in the expected API format, // and may be the result of another HTTP actor. // It supports wrapped errors and returns false when the error is nil. func IsUnexpectedServerError(err error) bool { … } // IsUnexpectedObjectError determines if err is due to an unexpected object from the master. // It supports wrapped errors and returns false when the error is nil. func IsUnexpectedObjectError(err error) bool { … } // SuggestsClientDelay returns true if this error suggests a client delay as well as the // suggested seconds to wait, or false if the error does not imply a wait. It does not // address whether the error *should* be retried, since some errors (like a 3xx) may // request delay without retry. // It supports wrapped errors and returns false when the error is nil. func SuggestsClientDelay(err error) (int, bool) { … } // ReasonForError returns the HTTP status for a particular error. // It supports wrapped errors and returns StatusReasonUnknown when // the error is nil or doesn't have a status. func ReasonForError(err error) metav1.StatusReason { … } func reasonAndCodeForError(err error) (metav1.StatusReason, int32) { … } type ErrorReporter … // NewClientErrorReporter will respond with valid v1.Status objects that report // unexpected server responses. Primarily used by watch to report errors when // we attempt to decode a response from the server and it is not in the form // we expect. Because watch is a dependency of the core api, we can't return // meta/v1.Status in that package and so much inject this interface to convert a // generic error as appropriate. The reason is passed as a unique status cause // on the returned status, otherwise the generic "ClientError" is returned. func NewClientErrorReporter(code int, verb string, reason string) *ErrorReporter { … } // AsObject returns a valid error runtime.Object (a v1.Status) for the given // error, using the code and verb of the reporter type. The error is set to // indicate that this was an unexpected server response. func (r *ErrorReporter) AsObject(err error) runtime.Object { … }