errors

package
v0.0.0-...-9b598c7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_CODE_PREFIX = "KAFKAS-MGMT"

	// HREF for API errors
	ERROR_HREF = "/api/kafkas_mgmt/v1/errors/"

	// To support connector errors too..
	CONNECTOR_MGMT_ERROR_CODE_PREFIX = "CONNECTOR-MGMT"
	CONNECTOR_MGMT_ERROR_HREF        = "/api/connector_mgmt/v1/errors/"

	// Forbidden occurs when a user is not allowed to access the service
	ErrorForbidden       ServiceErrorCode = 4
	ErrorForbiddenReason string           = "Forbidden to perform this action"

	// MaxAllowedInstanceReached occurs when a user or organisation has reached maximum number of allowed instances
	ErrorMaxAllowedInstanceReached       ServiceErrorCode = 5
	ErrorMaxAllowedInstanceReachedReason string           = "Forbidden to create more instances than the maximum allowed"

	// Conflict occurs when a database constraint is violated
	ErrorConflict       ServiceErrorCode = 6
	ErrorConflictReason string           = "An entity with the specified unique values already exists"

	// NotFound occurs when a record is not found in the database
	ErrorNotFound       ServiceErrorCode = 7
	ErrorNotFoundReason string           = "Resource not found"

	// Validation occurs when an object fails validation
	ErrorValidation       ServiceErrorCode = 8
	ErrorValidationReason string           = "General validation failure"

	// General occurs when an error fails to match any other error code
	ErrorGeneral       ServiceErrorCode = 9
	ErrorGeneralReason string           = "Unspecified error"

	// NotImplemented occurs when an API REST method is not implemented in a handler
	ErrorNotImplemented       ServiceErrorCode = 10
	ErrorNotImplementedReason string           = "HTTP Method not implemented for this endpoint"

	// Unauthorized occurs when the requester is not authorized to perform the specified action
	ErrorUnauthorized       ServiceErrorCode = 11
	ErrorUnauthorizedReason string           = "Account is unauthorized to perform this action"

	// Unauthorized occurs when the requester is not authorized to perform the specified action
	ErrorTermsNotAccepted       ServiceErrorCode = 12
	ErrorTermsNotAcceptedReason string           = "Required terms have not been accepted"

	// Unauthenticated occurs when the provided credentials cannot be validated
	ErrorUnauthenticated       ServiceErrorCode = 15
	ErrorUnauthenticatedReason string           = "Account authentication could not be verified"

	// MalformedRequest occurs when the request body cannot be read
	ErrorMalformedRequest       ServiceErrorCode = 17
	ErrorMalformedRequestReason string           = "Unable to read request body"

	// ServiceIsUnderMaintenance occurs when a user is unable to access the service due to ongoing maintenance
	ErrorServiceIsUnderMaintenance       ServiceErrorCode = 18
	ErrorServiceIsUnderMaintenanceReason string           = "Unable to perform this action, as the service is currently under maintenance"

	// Bad Request
	ErrorBadRequest       ServiceErrorCode = 21
	ErrorBadRequestReason string           = "Bad request"

	// Invalid Search Query
	ErrorFailedToParseSearch       ServiceErrorCode = 23
	ErrorFailedToParseSearchReason string           = "Failed to parse search query"

	// TooManyRequests occurs when a the kafka instances capacity gets filled up
	ErrorTooManyKafkaInstancesReached       ServiceErrorCode = 24
	ErrorTooManyKafkaInstancesReachedReason string           = "The maximum number of allowed kafka instances has been reached"

	// Gone occurs when a record is accessed that has been deleted
	ErrorGone       ServiceErrorCode = 25
	ErrorGoneReason string           = "Resource gone"

	// Synchronous request not supported
	ErrorSyncActionNotSupported       ServiceErrorCode = 103
	ErrorSyncActionNotSupportedReason string           = "Synchronous action is not supported, use async=true parameter"

	// Failed to create sso client - an internal error incurred when calling keycloak server
	ErrorFailedToCreateSSOClient       ServiceErrorCode = 106
	ErrorFailedToCreateSSOClientReason string           = "Failed to create kafka client in the mas sso"

	// Failed to get sso client secret  - an internal error incurred when calling keycloak server
	ErrorFailedToGetSSOClientSecret       ServiceErrorCode = 107
	ErrorFailedToGetSSOClientSecretReason string           = "Failed to get kafka client secret from the mas sso"

	// Failed to get sso client - an internal error incurred when calling keycloak server
	ErrorFailedToGetSSOClient       ServiceErrorCode = 108
	ErrorFailedToGetSSOClientReason string           = "Failed to get kafka client from the mas sso"

	// Failed to delete sso client - an internal error incurred when calling keycloak server
	ErrorFailedToDeleteSSOClient       ServiceErrorCode = 109
	ErrorFailedToDeleteSSOClientReason string           = "Failed to delete kafka client from the mas sso"

	// Failed to create service account, after validating user's request, but failed at the server end
	// it is an internal server error
	ErrorFailedToCreateServiceAccount       ServiceErrorCode = 110
	ErrorFailedToCreateServiceAccountReason string           = "Failed to create service account"

	// Failed to get service account - an internal error incurred when calling keycloak server
	ErrorFailedToGetServiceAccount       ServiceErrorCode = 111
	ErrorFailedToGetServiceAccountReason string           = "Failed to get service account"

	// Failed to delete service account - an internal error incurred when calling keycloak server
	ErrorFailedToDeleteServiceAccount       ServiceErrorCode = 112
	ErrorFailedToDeleteServiceAccountReason string           = "Failed to delete service account"

	// Failed to find service account - a client error as incorrect SA is given
	ErrorServiceAccountNotFound       ServiceErrorCode = 113
	ErrorServiceAccountNotFoundReason string           = "Failed to find service account"

	ErrorMaxLimitForServiceAccountsReached       ServiceErrorCode = 115
	ErrorMaxLimitForServiceAccountsReachedReason string           = "Max limit for the service account creation has reached"

	// Insufficient quota
	ErrorInsufficientQuota       ServiceErrorCode = 120
	ErrorInsufficientQuotaReason string           = "Insufficient quota"
	// Failed to check Quota
	ErrorFailedToCheckQuota       ServiceErrorCode = 121
	ErrorFailedToCheckQuotaReason string           = "Failed to check quota"
	// Provider not supported
	ErrorProviderNotSupported       ServiceErrorCode = 30
	ErrorProviderNotSupportedReason string           = "Provider not supported"

	// Region not supported
	ErrorRegionNotSupported       ServiceErrorCode = 31
	ErrorRegionNotSupportedReason string           = "Region not supported"

	// Invalid kafka cluster name
	ErrorMalformedKafkaClusterName       ServiceErrorCode = 32
	ErrorMalformedKafkaClusterNameReason string           = "Kafka cluster name is invalid"

	// Minimum field length validation
	ErrorMinimumFieldLength       ServiceErrorCode = 33
	ErrorMinimumFieldLengthReason string           = "Minimum field length not reached"

	// Maximum field length validation
	ErrorMaximumFieldLength       ServiceErrorCode = 34
	ErrorMaximumFieldLengthReason string           = "Maximum field length has been depassed"

	// Kafka cluster name must be unique
	ErrorDuplicateKafkaClusterName       ServiceErrorCode = 36
	ErrorDuplicateKafkaClusterNameReason string           = "Kafka cluster name is already used"

	// A generic field validation error when validating API requests input
	ErrorFieldValidationError       ServiceErrorCode = 37
	ErrorFieldValidationErrorReason string           = "Field validation failed"

	// Failure to send an error response (i.e. unable to send error response as the error can't be converted to JSON.)
	ErrorUnableToSendErrorResponse       ServiceErrorCode = 1000
	ErrorUnableToSendErrorResponseReason string           = "An unexpected error happened, please check the log of the service for details"

	// Invalid service account name
	ErrorMalformedServiceAccountName       ServiceErrorCode = 38
	ErrorMalformedServiceAccountNameReason string           = "Service account name is invalid"

	// Invalid service account desc
	ErrorMalformedServiceAccountDesc       ServiceErrorCode = 39
	ErrorMalformedServiceAccountDescReason string           = "Service account desc is invalid"

	// Invalid service account desc
	ErrorMalformedServiceAccountId       ServiceErrorCode = 40
	ErrorMalformedServiceAccountIdReason string           = "Service account id is invalid"

	// Instance type not supported
	ErrorInstanceTypeNotSupported       ServiceErrorCode = 41
	ErrorInstanceTypeNotSupportedReason string           = "Instance Type not supported"

	// Instance plan not supported
	ErrorInstancePlanNotSupported       ServiceErrorCode = 42
	ErrorInstancePlanNotSupportedReason string           = "Instance plan not supported"

	// Billing account id missing or invalid
	ErrorBillingAccountInvalid       ServiceErrorCode = 43
	ErrorBillingAccountInvalidReason string           = "Billing account id missing or invalid"

	// Enterprise cluster id must be unique
	ErrorDuplicateClusterId       ServiceErrorCode = 44
	ErrorDuplicateClusterIdReason string           = "Enterprise cluster ID is already used"

	// Enterprise cluster id is invalid
	ErrorInvalidClusterId       ServiceErrorCode = 45
	ErrorInvalidClusterIdReason string           = "Enterprise cluster ID is invalid"

	// Enterprise cluster external id is invalid
	ErrorInvalidExternalClusterId       ServiceErrorCode = 46
	ErrorInvalidExternalClusterIdReason string           = "Enterprise external cluster ID is invalid"

	// Dns name is invalid
	ErrorInvalidDnsName       ServiceErrorCode = 47
	ErrorInvalidDnsNameReason string           = "Dns name is invalid"

	// Too Many requests error. Used by rate limiting
	ErrorTooManyRequests       ServiceErrorCode = 429
	ErrorTooManyRequestsReason string           = "Too many requests"
)

Variables

This section is empty.

Functions

func CodeStr

func CodeStr(code ServiceErrorCode) string

func Href

func Href(code ServiceErrorCode) string

Types

type ErrorList

type ErrorList []error

func (*ErrorList) AddErrors

func (e *ErrorList) AddErrors(errs ...error)

AddErrors adds the provided list of errors to the ErrorList. If the provided list of errors contain error elements that are of type ErrorList those are recursively "unrolled" so the result does not contain appended ErrorList elements. The method modifies the underlying slice.

func (ErrorList) Error

func (e ErrorList) Error() string

func (ErrorList) IsEmpty

func (e ErrorList) IsEmpty() bool

func (ErrorList) ToErrorSlice

func (e ErrorList) ToErrorSlice() []error

ToErrorSlice returns the ErrorList as a slice of error

type ServiceError

type ServiceError struct {
	// Code is the numeric and distinct ID for the error
	Code ServiceErrorCode
	// Reason is the context-specific reason the error was generated
	Reason string
	// HttpCode is the HttpCode associated with the error when the error is returned as an API response
	HttpCode int
	// contains filtered or unexported fields
}

func BadRequest

func BadRequest(reason string, values ...interface{}) *ServiceError

func Conflict

func Conflict(reason string, values ...interface{}) *ServiceError

func DuplicateClusterId

func DuplicateClusterId() *ServiceError

func DuplicateKafkaClusterName

func DuplicateKafkaClusterName() *ServiceError

func FailedToCheckQuota

func FailedToCheckQuota(reason string, values ...interface{}) *ServiceError

func FailedToCreateSSOClient

func FailedToCreateSSOClient(reason string, values ...interface{}) *ServiceError

func FailedToCreateServiceAccount

func FailedToCreateServiceAccount(reason string, values ...interface{}) *ServiceError

func FailedToDeleteSSOClient

func FailedToDeleteSSOClient(reason string, values ...interface{}) *ServiceError

func FailedToDeleteServiceAccount

func FailedToDeleteServiceAccount(reason string, values ...interface{}) *ServiceError

func FailedToGetSSOClient

func FailedToGetSSOClient(reason string, values ...interface{}) *ServiceError

func FailedToGetSSOClientSecret

func FailedToGetSSOClientSecret(reason string, values ...interface{}) *ServiceError

func FailedToGetServiceAccount

func FailedToGetServiceAccount(reason string, values ...interface{}) *ServiceError

func FailedToParseQueryParms

func FailedToParseQueryParms(reason string, values ...interface{}) *ServiceError

func FailedToParseSearch

func FailedToParseSearch(reason string, values ...interface{}) *ServiceError

func FieldValidationError

func FieldValidationError(reason string, values ...interface{}) *ServiceError

func Find

func Find(code ServiceErrorCode) (bool, *ServiceError)

func Forbidden

func Forbidden(reason string, values ...interface{}) *ServiceError

func GeneralError

func GeneralError(reason string, values ...interface{}) *ServiceError

func InstancePlanNotSupported

func InstancePlanNotSupported(reason string, values ...interface{}) *ServiceError

func InstanceTypeNotSupported

func InstanceTypeNotSupported(reason string, values ...interface{}) *ServiceError

func InsufficientQuotaError

func InsufficientQuotaError(reason string, values ...interface{}) *ServiceError

func InvalidBillingAccount

func InvalidBillingAccount(reason string, values ...interface{}) *ServiceError

func InvalidClusterId

func InvalidClusterId(reason string, values ...interface{}) *ServiceError

func InvalidDnsName

func InvalidDnsName(reason string, values ...interface{}) *ServiceError

func InvalidExternalClusterId

func InvalidExternalClusterId(reason string, values ...interface{}) *ServiceError

func Maintenance

func Maintenance(reason string, values ...interface{}) *ServiceError

func MalformedKafkaClusterName

func MalformedKafkaClusterName(reason string, values ...interface{}) *ServiceError

func MalformedRequest

func MalformedRequest(reason string, values ...interface{}) *ServiceError

func MalformedServiceAccountDesc

func MalformedServiceAccountDesc(reason string, values ...interface{}) *ServiceError

func MalformedServiceAccountId

func MalformedServiceAccountId(reason string, values ...interface{}) *ServiceError

func MalformedServiceAccountName

func MalformedServiceAccountName(reason string, values ...interface{}) *ServiceError

func MaxLimitForServiceAccountReached

func MaxLimitForServiceAccountReached(reason string, values ...interface{}) *ServiceError

func MaximumAllowedInstanceReached

func MaximumAllowedInstanceReached(reason string, values ...interface{}) *ServiceError

func MaximumFieldLengthExceeded

func MaximumFieldLengthExceeded(reason string, values ...interface{}) *ServiceError

func MinimumFieldLengthNotReached

func MinimumFieldLengthNotReached(reason string, values ...interface{}) *ServiceError

func New

func New(code ServiceErrorCode, reason string, values ...interface{}) *ServiceError

Reason can be a string with format verbs, which will be replace by the specified values

func NewErrorFromHTTPStatusCode

func NewErrorFromHTTPStatusCode(httpCode int, reason string, values ...interface{}) *ServiceError

func NewWithCause

func NewWithCause(code ServiceErrorCode, cause error, reason string, values ...interface{}) *ServiceError

func NotFound

func NotFound(reason string, values ...interface{}) *ServiceError

func NotImplemented

func NotImplemented(reason string, values ...interface{}) *ServiceError

func ProviderNotSupported

func ProviderNotSupported(reason string, values ...interface{}) *ServiceError

func RegionNotSupported

func RegionNotSupported(reason string, values ...interface{}) *ServiceError

func ServiceAccountNotFound

func ServiceAccountNotFound(reason string, values ...interface{}) *ServiceError

func SyncActionNotSupported

func SyncActionNotSupported() *ServiceError

func TermsNotAccepted

func TermsNotAccepted(reason string, values ...interface{}) *ServiceError

func ToServiceError

func ToServiceError(err error) *ServiceError

func TooManyKafkaInstancesReached

func TooManyKafkaInstancesReached(reason string, values ...interface{}) *ServiceError

func UnableToSendErrorResponse

func UnableToSendErrorResponse() *ServiceError

func Unauthenticated

func Unauthenticated(reason string, values ...interface{}) *ServiceError

func Unauthorized

func Unauthorized(reason string, values ...interface{}) *ServiceError

func Validation

func Validation(reason string, values ...interface{}) *ServiceError

func (*ServiceError) AsError

func (e *ServiceError) AsError() error

func (*ServiceError) AsOpenapiError

func (e *ServiceError) AsOpenapiError(operationID string, basePath string) compat.Error

func (*ServiceError) Error

func (e *ServiceError) Error() string

func (*ServiceError) InSufficientQuota

func (e *ServiceError) InSufficientQuota() bool

func (*ServiceError) Is404

func (e *ServiceError) Is404() bool

func (*ServiceError) IsBadRequest

func (e *ServiceError) IsBadRequest() bool

func (*ServiceError) IsClientErrorClass

func (e *ServiceError) IsClientErrorClass() bool

func (*ServiceError) IsConflict

func (e *ServiceError) IsConflict() bool

func (*ServiceError) IsFailedToCheckQuota

func (e *ServiceError) IsFailedToCheckQuota() bool

func (*ServiceError) IsFailedToCreateSSOClient

func (e *ServiceError) IsFailedToCreateSSOClient() bool

func (*ServiceError) IsFailedToCreateServiceAccount

func (e *ServiceError) IsFailedToCreateServiceAccount() bool

func (*ServiceError) IsFailedToDeleteSSOClient

func (e *ServiceError) IsFailedToDeleteSSOClient() bool

func (*ServiceError) IsFailedToDeleteServiceAccount

func (e *ServiceError) IsFailedToDeleteServiceAccount() bool

func (*ServiceError) IsFailedToGetSSOClient

func (e *ServiceError) IsFailedToGetSSOClient() bool

func (*ServiceError) IsFailedToGetSSOClientSecret

func (e *ServiceError) IsFailedToGetSSOClientSecret() bool

func (*ServiceError) IsFailedToGetServiceAccount

func (e *ServiceError) IsFailedToGetServiceAccount() bool

func (*ServiceError) IsForbidden

func (e *ServiceError) IsForbidden() bool

func (*ServiceError) IsInstanceTypeNotSupported

func (e *ServiceError) IsInstanceTypeNotSupported() bool

func (*ServiceError) IsMaxLimitForServiceAccountReached

func (e *ServiceError) IsMaxLimitForServiceAccountReached() bool

func (*ServiceError) IsServerErrorClass

func (e *ServiceError) IsServerErrorClass() bool

func (*ServiceError) IsServiceAccountNotFound

func (e *ServiceError) IsServiceAccountNotFound() bool

func (*ServiceError) Recoverable

func (e *ServiceError) Recoverable() bool

func (*ServiceError) StackTrace

func (e *ServiceError) StackTrace() errors.StackTrace

StackTrace returns errors stacktrace.

func (*ServiceError) Unwrap

func (e *ServiceError) Unwrap() error

Unwrap returns the original error that caused the ServiceError. Can be used with errors.Unwrap.

type ServiceErrorBuilder

type ServiceErrorBuilder interface {
	Wrap(serviceError ServiceError) ServiceErrorBuilder
	WithCode(code ServiceErrorCode) ServiceErrorBuilder
	WithReason(reason string, values ...any) ServiceErrorBuilder
	WithHttpCode(httpCode int) ServiceErrorBuilder
	WithCause(cause error) ServiceErrorBuilder
	Recoverable() ServiceErrorBuilder
	Build() *ServiceError
}

func NewServiceErrorBuilder

func NewServiceErrorBuilder() ServiceErrorBuilder

type ServiceErrorCode

type ServiceErrorCode int

type ServiceErrors

type ServiceErrors []ServiceError

func Errors

func Errors() ServiceErrors

Jump to

Keyboard shortcuts

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