errors

package
v2.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgDeployNamespaceMismatchError    = "MSG_DEPLOY_NAMESPACE_MISMATCH_ERROR"
	MsgDeployEmptyNamespaceError       = "MSG_DEPLOY_EMPTY_NAMESPACE_ERROR"
	MsgLoginUnauthorizedError          = "MSG_LOGIN_UNAUTHORIZED_ERROR"
	MsgEncryptionKeyChanged            = "MSG_ENCRYPTION_KEY_CHANGED"
	MsgDashboardExclusiveResourceError = "MSG_DASHBOARD_EXCLUSIVE_RESOURCE_ERROR"
	MsgTokenExpiredError               = "MSG_TOKEN_EXPIRED_ERROR"
)

Errors that can be used directly without localizing

Variables

NonCriticalErrors is an array of error statuses, that are non-critical. That means, that this error can be silenced and displayed to the user as a warning on the frontend side.

Functions

func AppendError

func AppendError(err error, nonCriticalErrors []error) ([]error, error)

AppendError handles single error, that occurred during API GET call. If it is not critical, then it will be returned as a part of error array. Otherwise, it will be returned as a second value. Usage of this functions allows to distinguish critical errors from non-critical ones. It is needed to handle them in a different way.

func HandleError

func HandleError(err error) ([]error, error)

HandleError handles single error, that occurred during API GET call. If it is not critical, then it will be returned as a part of error array. Otherwise, it will be returned as a second value. Usage of this functions allows to distinguish critical errors from non-critical ones. It is needed to handle them in a different way.

func HandleHTTPError

func HandleHTTPError(err error) int

HandleHTTPError is used to handle HTTP Errors more accurately based on the localized consts

func HandleInternalError

func HandleInternalError(response *restful.Response, err error)

HandleInternalError writes the given error to the response and sets appropriate HTTP status headers.

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists.

func IsForbiddenError

func IsForbiddenError(err error) bool

IsForbiddenError returns true if given error has code 403, false otherwise.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true when the given error is 404-NotFound error.

func IsTokenExpired

func IsTokenExpired(err error) bool

IsTokenExpired determines if the err is an error which errStatus' message is MsgTokenExpiredError

func IsTokenExpiredError

func IsTokenExpiredError(err error) bool

IsTokenExpiredError determines if the err is the MsgTokenExpiredError.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized determines if err is an error which indicates that the request is unauthorized and requires authentication by the user.

func LocalizeError

func LocalizeError(err error) error

LocalizeError returns error code (string) that can be used by frontend to localize error message.

func MergeErrors

func MergeErrors(errorArraysToMerge ...[]error) (mergedErrors []error)

MergeErrors merges multiple non-critical error arrays into one array.

func NewBadRequest

func NewBadRequest(reason string) *errors.StatusError

NewBadRequest creates an error that indicates that the request is invalid and can not be processed.

func NewGenericResponse

func NewGenericResponse(code int, serverMessage string) *errors.StatusError

NewGenericResponse return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches by switch the error code.

func NewInternal

func NewInternal(reason string) *errors.StatusError

NewInternal return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

func NewInvalid

func NewInvalid(reason string) *errors.StatusError

NewInvalid return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

func NewNotFound

func NewNotFound(reason string) *errors.StatusError

NewNotFound return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

func NewTokenExpired

func NewTokenExpired(reason string) *errors.StatusError

NewTokenExpired return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

func NewUnauthorized

func NewUnauthorized(reason string) *errors.StatusError

NewUnauthorized returns an error indicating the client is not authorized to perform the requested action.

func NewUnexpectedObject

func NewUnexpectedObject(obj runtime.Object) *errors.StatusError

NewUnexpectedObject return a statusError which is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL