{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\n## Constants\n\n```go\nconst (\n\tErrorTypeBase             = \"https://api.hyperfleet.io/errors/\"\n\tErrorTypeValidation       = ErrorTypeBase + \"validation-error\"\n\tErrorTypeAuth             = ErrorTypeBase + \"authentication-error\"\n\tErrorTypePermissionDenied = ErrorTypeBase + \"permission-denied\"\n\tErrorTypeNotFound         = ErrorTypeBase + \"not-found\"\n\tErrorTypeConflict         = ErrorTypeBase + \"conflict\"\n\tErrorTypeRateLimit        = ErrorTypeBase + \"rate-limit\"\n\tErrorTypeInternal         = ErrorTypeBase + \"internal-error\"\n\tErrorTypeService          = ErrorTypeBase + \"service-unavailable\"\n\tErrorTypeBadRequest       = ErrorTypeBase + \"bad-request\"\n\tErrorTypeMalformed        = ErrorTypeBase + \"malformed-request\"\n\tErrorTypeNotImpl          = ErrorTypeBase + \"not-implemented\"\n)\n```\nError type URIs for RFC 9457\n\n```go\nconst (\n\t// Validation errors (VAL) - 400/422\n\tCodeValidationMultiple = \"HYPERFLEET-VAL-000\"\n\tCodeValidationRequired = \"HYPERFLEET-VAL-001\"\n\tCodeValidationInvalid  = \"HYPERFLEET-VAL-002\"\n\tCodeValidationFormat   = \"HYPERFLEET-VAL-003\"\n\tCodeValidationRange    = \"HYPERFLEET-VAL-004\"\n\n\t// Authentication errors (AUT) - 401\n\tCodeAuthNoCredentials      = \"HYPERFLEET-AUT-001\" //nolint:gosec // Not actual credentials, just error code names\n\tCodeAuthInvalidCredentials = \"HYPERFLEET-AUT-002\" //nolint:gosec // Not actual credentials, just error code names\n\tCodeAuthExpiredToken       = \"HYPERFLEET-AUT-003\" //nolint:gosec // Not actual credentials, just error code names\n\n\t// Authorization errors (AUZ) - 403\n\tCodeAuthzPermissionDenied = \"HYPERFLEET-AUZ-001\" //nolint:gosec // Not actual credentials, just error code names\n\n\t// Not Found errors (NTF) - 404\n\tCodeNotFoundEndpoint = \"HYPERFLEET-NTF-000\"\n\tCodeNotFoundGeneric  = \"HYPERFLEET-NTF-001\"\n\tCodeNotFoundCluster  = \"HYPERFLEET-NTF-002\"\n\tCodeNotFoundNodePool = \"HYPERFLEET-NTF-003\"\n\n\t// Conflict errors (CNF) - 409\n\tCodeConflictExists  = \"HYPERFLEET-CNF-001\"\n\tCodeConflictVersion = \"HYPERFLEET-CNF-002\"\n\tCodeConflictState   = \"HYPERFLEET-CNF-003\"\n\n\t// Rate Limit errors (LMT) - 429\n\tCodeRateLimitExceeded = \"HYPERFLEET-LMT-001\"\n\n\t// Internal errors (INT) - 500\n\tCodeInternalGeneral  = \"HYPERFLEET-INT-001\"\n\tCodeInternalDatabase = \"HYPERFLEET-INT-002\"\n\n\t// Service errors (SVC) - 502/503/504\n\tCodeServiceUnavailable = \"HYPERFLEET-SVC-001\"\n\tCodeServiceTimeout     = \"HYPERFLEET-SVC-002\"\n\n\t// Bad Request errors\n\tCodeBadRequest      = \"HYPERFLEET-VAL-005\"\n\tCodeMalformedBody   = \"HYPERFLEET-VAL-006\"\n\tCodeSearchParseFail = \"HYPERFLEET-VAL-007\"\n\tCodeNotImplemented  = \"HYPERFLEET-INT-003\"\n)\n```\nError codes in HYPERFLEET-CAT-NUM format\n\n## Types\n\n```go\ntype ServiceError struct {\n\tRFC9457Code string\n\tType        string\n\tTitle       string\n\tReason      string\n\tDetails     []ValidationDetail\n\tHTTPCode    int\n}\n```\nServiceError represents an API error with RFC 9457 Problem Details support\n\n```go\nfunc BadRequest(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc Conflict(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc ConflictState(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc DatabaseAdvisoryLock(err error) *ServiceError\n```\n\n```go\nfunc FailedToParseSearch(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc Find(code string) (bool, *ServiceError)\n```\nFind looks up an error definition by its RFC 9457 code\n\n```go\nfunc Forbidden(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc GeneralError(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc InvalidToken(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc MalformedRequest(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc New(code string, reason string, values ...interface{}) *ServiceError\n```\nNew creates a new ServiceError with optional custom reason\n\n```go\nfunc NotFound(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc NotImplemented(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc ServiceUnavailable(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc Unauthenticated(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc Validation(reason string, values ...interface{}) *ServiceError\n```\n\n```go\nfunc ValidationWithDetails(reason string, details []ValidationDetail) *ServiceError\n```\nValidationWithDetails creates a validation error with field-level details\n\n```go\nfunc (e *ServiceError) AsError() error\n```\n\n```go\nfunc (e *ServiceError) AsProblemDetails(instance string, traceID string) openapi.ProblemDetails\n```\nAsProblemDetails converts the ServiceError to RFC 9457 Problem Details format\n\n```go\nfunc (e *ServiceError) Error() string\n```\n\n```go\nfunc (e *ServiceError) Is404() bool\n```\n\n```go\nfunc (e *ServiceError) IsConflict() bool\n```\n\n```go\ntype ServiceErrors []ServiceError\n```\n\n```go\ntype ValidationDetail struct {\n\tField      string      `json:\"field\"`\n\tValue      interface{} `json:\"value,omitempty\"`\n\tConstraint string      `json:\"constraint,omitempty\"`\n\tMessage    string      `json:\"message\"`\n}\n```\nValidationDetail represents a single field validation error (RFC 9457 format)\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/errors","name":"errors","synopsis":"","isRedistributable":true}
