Documentation
¶
Index ¶
- Constants
- func IsRetryable(err error) bool
- type CredentialErrorDetails
- type CredentialErrorTarget
- type FieldError
- type OperationError
- type RetryableError
- type ServiceError
- func BadRequest(reason string, values ...interface{}) *ServiceError
- func ComputeAccessInactive() *ServiceError
- func ComputeQuotaExceeded(reason string, values ...interface{}) *ServiceError
- func Conflict(reason string, values ...interface{}) *ServiceError
- func CredentialsInvalid(target CredentialErrorTarget, reason string, values ...interface{}) *ServiceError
- func CredentialsRequired(target CredentialErrorTarget, reason string, values ...interface{}) *ServiceError
- func Find(code ServiceErrorCode) (bool, *ServiceError)
- func Forbidden(reason string, values ...interface{}) *ServiceError
- func GeneralError(reason string, values ...interface{}) *ServiceError
- func Gone(reason string, values ...interface{}) *ServiceError
- func InternalServerError(reason string, values ...interface{}) *ServiceError
- func MalformedRequest(reason string, values ...interface{}) *ServiceError
- func New(code ServiceErrorCode, reason string, values ...interface{}) *ServiceError
- func NotFound(reason string, values ...interface{}) *ServiceError
- func NotImplemented(reason string, values ...interface{}) *ServiceError
- func SharedComputeCapacityReached() *ServiceError
- func TooManyRequests(reason string, values ...interface{}) *ServiceError
- func Unauthenticated(reason string, values ...interface{}) *ServiceError
- func Unauthorized(reason string, values ...interface{}) *ServiceError
- func UnprocessableEntity(reason string, values ...interface{}) *ServiceError
- func Validation(reason string, values ...interface{}) *ServiceError
- func ValidationFailed(fieldErrors []FieldError) *ServiceError
- func (e *ServiceError) AsError() error
- func (e *ServiceError) AsOpenapiError() openapi.Error
- func (e *ServiceError) Error() string
- func (e *ServiceError) Is404() bool
- func (e *ServiceError) IsConflict() bool
- func (e *ServiceError) IsForbidden() bool
- func (e *ServiceError) WithDetails(details any) *ServiceError
- func (e *ServiceError) WithPrefix(format string, a ...interface{}) *ServiceError
- type ServiceErrorCode
- type ServiceErrors
- type ValidationErrorDetails
Constants ¶
const ( ErrorCodeCredentialsRequired = "credentials_required" ErrorCodeCredentialsInvalid = "credentials_invalid" )
Structured error detail codes.
const ( CredentialTargetKindGitClone = "git_clone" CredentialTargetKindImagePull = "image_pull" CredentialTargetKindImagePush = "image_push" )
Kinds of credential targets for structured credential errors.
const ( // resource shape VErrResourceNameRequired = "resource_name_required" VErrResourceNameInvalid = "resource_name_invalid" VErrResourceNameDuplicate = "resource_name_duplicate" VErrSourceRequired = "source_required" VErrSourceConflict = "source_conflict" VErrWorkloadTypeInvalid = "workload_type_invalid" VErrScheduleRequired = "schedule_required" VErrScheduleNotAllowed = "schedule_not_allowed" VErrScheduleInvalid = "schedule_invalid" VErrReplicasInvalid = "replicas_invalid" // ports VErrPortsNotAllowed = "ports_not_allowed" VErrPublicPortNotHTTP = "public_port_not_http" VErrPortProtocolInvalid = "port_protocol_invalid" VErrPortNameInvalid = "port_name_invalid" VErrPortNumberInvalid = "port_number_invalid" VErrPortNameDuplicate = "port_name_duplicate" VErrPortNumberDuplicate = "port_number_duplicate" VErrSubdomainDuplicate = "subdomain_duplicate" VErrDomainNotConfigured = "domain_not_configured" // postgres addons VErrPostgresExternalImportDisabled = "postgres_external_import_disabled" // env VErrEnvNameRequired = "env_name_required" VErrEnvNameDuplicate = "env_name_duplicate" VErrEnvValueMissing = "env_value_missing" VErrEnvValueConflict = "env_value_conflict" VErrEnvSelfOutputUnknown = "env_self_output_unknown" // volume mounts VErrVolumeMountInvalid = "volume_mount_invalid" VErrVolumeNotFound = "volume_not_found" VErrVolumeHashMissing = "volume_hash_missing" // referenced entities VErrSecretNotFound = "secret_not_found" VErrGitIntegrationNotFound = "git_integration_not_found" VErrRegistryCredentialNotFound = "registry_credential_not_found" // depends_on VErrDependencySelf = "self_dependency" VErrDependencyDuplicate = "duplicate_dependency" VErrDependencyUnknown = "unknown_dependency" VErrDependencyCycle = "dependency_cycle" // build / git / image source shape VErrGitRepoURLRequired = "git_repo_url_required" VErrGitBranchTagConflict = "git_branch_tag_conflict" VErrGitCommitInvalid = "git_commit_invalid" VErrGitCommitRequiresRef = "git_commit_requires_ref" VErrImageRefRequired = "image_ref_required" VErrImageRefInvalid = "image_ref_invalid" VErrPushTargetRequired = "push_target_required" VErrPushTargetConflict = "push_target_conflict" VErrPushRefInvalid = "push_ref_invalid" // release-time (sync resolvePins + async worker) VErrGitRepoUnreachable = "git_repo_unreachable" VErrGitAuthFailed = "git_auth_failed" VErrGitBranchNotFound = "git_branch_not_found" VErrGitTagNotFound = "git_tag_not_found" VErrGitRateLimited = "git_rate_limited" VErrImageNotFound = "image_not_found" // VErrRegistryCredentialsRequired means the registry rejected anonymous // access and NO credentials were configured for it — the fix is adding // credentials, not correcting them (that case is VErrRegistryAuthFailed // / VErrPushAccessDenied). VErrRegistryCredentialsRequired = "registry_credentials_required" VErrRegistryAuthFailed = "registry_auth_failed" VErrPushAccessDenied = "push_access_denied" // stack-level (name, settings, connections, interpolations) VErrStackNameInvalid = "stack_name_invalid" VErrStackSettingsInvalid = "stack_settings_invalid" VErrConnectionInvalid = "connection_invalid" )
Validation error codes surfaced in FieldError.Code. Shared by create-time validation and release-time checks; the frontend switches on these.
Variables ¶
This section is empty.
Functions ¶
func IsRetryable ¶
Types ¶
type CredentialErrorDetails ¶
type CredentialErrorDetails struct {
Code string `json:"code"`
Target CredentialErrorTarget `json:"target"`
}
CredentialErrorDetails is the structured payload for credential errors.
type CredentialErrorTarget ¶
type CredentialErrorTarget struct {
Kind string `json:"kind"`
Host string `json:"host"`
Ref string `json:"ref"`
}
CredentialErrorTarget identifies what a credential error is about.
type FieldError ¶
type FieldError struct {
Field string `json:"field"`
Code string `json:"code"`
Message string `json:"message"`
}
FieldError is one machine-readable validation failure, addressed to a field of the request body (JSON path, e.g. "ports[0].protocol").
type OperationError ¶
func Permanent ¶
func Permanent(reason, message string) *OperationError
func Transient ¶
func Transient(reason, message string) *OperationError
func (*OperationError) Error ¶
func (e *OperationError) Error() string
func (*OperationError) IsRetryable ¶
func (e *OperationError) IsRetryable() bool
func (*OperationError) Unwrap ¶
func (e *OperationError) Unwrap() error
type RetryableError ¶
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
// HttopCode is the HttpCode associated with the error when the error is returned as an API response
HttpCode int
// Details optionally carries structured, machine-readable error context
// that is serialized into the API error response.
Details any
}
func BadRequest ¶
func BadRequest(reason string, values ...interface{}) *ServiceError
func ComputeAccessInactive ¶
func ComputeAccessInactive() *ServiceError
func ComputeQuotaExceeded ¶
func ComputeQuotaExceeded(reason string, values ...interface{}) *ServiceError
func Conflict ¶
func Conflict(reason string, values ...interface{}) *ServiceError
func CredentialsInvalid ¶
func CredentialsInvalid(target CredentialErrorTarget, reason string, values ...interface{}) *ServiceError
CredentialsInvalid returns a 400 telling the client the configured credentials for a target failed.
func CredentialsRequired ¶
func CredentialsRequired(target CredentialErrorTarget, reason string, values ...interface{}) *ServiceError
CredentialsRequired returns a 400 telling the client which target needs credentials that were not supplied.
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 Gone ¶
func Gone(reason string, values ...interface{}) *ServiceError
func InternalServerError ¶
func InternalServerError(reason string, values ...interface{}) *ServiceError
func MalformedRequest ¶
func MalformedRequest(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 NotFound ¶
func NotFound(reason string, values ...interface{}) *ServiceError
func NotImplemented ¶
func NotImplemented(reason string, values ...interface{}) *ServiceError
func SharedComputeCapacityReached ¶
func SharedComputeCapacityReached() *ServiceError
func TooManyRequests ¶
func TooManyRequests(reason string, values ...interface{}) *ServiceError
func Unauthenticated ¶
func Unauthenticated(reason string, values ...interface{}) *ServiceError
func Unauthorized ¶
func Unauthorized(reason string, values ...interface{}) *ServiceError
func UnprocessableEntity ¶
func UnprocessableEntity(reason string, values ...interface{}) *ServiceError
func Validation ¶
func Validation(reason string, values ...interface{}) *ServiceError
func ValidationFailed ¶
func ValidationFailed(fieldErrors []FieldError) *ServiceError
ValidationFailed returns a 400 carrying every collected field error.
func (*ServiceError) AsError ¶
func (e *ServiceError) AsError() error
func (*ServiceError) AsOpenapiError ¶
func (e *ServiceError) AsOpenapiError() openapi.Error
func (*ServiceError) Error ¶
func (e *ServiceError) Error() string
func (*ServiceError) Is404 ¶
func (e *ServiceError) Is404() bool
func (*ServiceError) IsConflict ¶
func (e *ServiceError) IsConflict() bool
func (*ServiceError) IsForbidden ¶
func (e *ServiceError) IsForbidden() bool
func (*ServiceError) WithDetails ¶
func (e *ServiceError) WithDetails(details any) *ServiceError
WithDetails attaches structured details to the error.
func (*ServiceError) WithPrefix ¶
func (e *ServiceError) WithPrefix(format string, a ...interface{}) *ServiceError
type ServiceErrorCode ¶
type ServiceErrorCode int
const ( // InvalidToken occurs when a token is invalid (generally, not found in the database) ErrorInvalidToken ServiceErrorCode = 1 // Forbidden occurs when a user has been blacklisted ErrorForbidden ServiceErrorCode = 4 // Conflict occurs when a database constraint is violated ErrorConflict ServiceErrorCode = 6 // NotFound occurs when a record is not found in the database ErrorNotFound ServiceErrorCode = 7 // Validation occurs when an object fails validation ErrorValidation ServiceErrorCode = 8 // General occurs when an error fails to match any other error code ErrorGeneral ServiceErrorCode = 9 // NotImplemented occurs when an API REST method is not implemented in a handler ErrorNotImplemented ServiceErrorCode = 10 ErrorUnauthorized ServiceErrorCode = 11 // Unauthenticated occurs when the provided credentials cannot be validated ErrorUnauthenticated ServiceErrorCode = 15 // MalformedRequest occurs when the request body cannot be read ErrorMalformedRequest ServiceErrorCode = 17 // Bad Request ErrorBadRequest ServiceErrorCode = 21 // Gone ErrorGone ServiceErrorCode = 24 // Too Many Requests ErrorTooManyRequests ServiceErrorCode = 25 // Unprocessable Entity ErrorUnprocessableEntity ServiceErrorCode = 26 // InternalServerError ErrorInternalServerError ServiceErrorCode = 27 // ComputeAccessInactive occurs when an organisation's compute entitlement or lease is inactive. ErrorComputeAccessInactive ServiceErrorCode = 28 ErrorSharedComputeCapacityReached ServiceErrorCode = 29 // ComputeQuotaExceeded occurs when a configured managed-compute limit is exceeded. ErrorComputeQuotaExceeded ServiceErrorCode = 30 )
type ValidationErrorDetails ¶
type ValidationErrorDetails struct {
Errors []FieldError `json:"errors"`
}
ValidationErrorDetails is the structured payload carried in Error.details for aggregated validation failures.