errors

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrorTypeBase       = "https://api.hyperfleet.io/errors/"
	ErrorTypeValidation = ErrorTypeBase + "validation-error"
	ErrorTypeAuth       = ErrorTypeBase + "authentication-error"
	ErrorTypeAuthz      = ErrorTypeBase + "authorization-error"
	ErrorTypeNotFound   = ErrorTypeBase + "not-found"
	ErrorTypeConflict   = ErrorTypeBase + "conflict"
	ErrorTypeRateLimit  = ErrorTypeBase + "rate-limit"
	ErrorTypeInternal   = ErrorTypeBase + "internal-error"
	ErrorTypeService    = ErrorTypeBase + "service-unavailable"
	ErrorTypeBadRequest = ErrorTypeBase + "bad-request"
	ErrorTypeMalformed  = ErrorTypeBase + "malformed-request"
	ErrorTypeNotImpl    = ErrorTypeBase + "not-implemented"
)

Error type URIs for RFC 9457

View Source
const (
	// Validation errors (VAL) - 400/422
	CodeValidationMultiple = "HYPERFLEET-VAL-000"
	CodeValidationRequired = "HYPERFLEET-VAL-001"
	CodeValidationInvalid  = "HYPERFLEET-VAL-002"
	CodeValidationFormat   = "HYPERFLEET-VAL-003"
	CodeValidationRange    = "HYPERFLEET-VAL-004"

	// Authentication errors (AUT) - 401
	CodeAuthNoCredentials      = "HYPERFLEET-AUT-001" //nolint:gosec // Not actual credentials, just error code names
	CodeAuthInvalidCredentials = "HYPERFLEET-AUT-002" //nolint:gosec // Not actual credentials, just error code names
	CodeAuthExpiredToken       = "HYPERFLEET-AUT-003" //nolint:gosec // Not actual credentials, just error code names

	// Authorization errors (AUZ) - 403
	CodeAuthzInsufficient = "HYPERFLEET-AUZ-001"
	CodeAuthzForbidden    = "HYPERFLEET-AUZ-002"

	// Not Found errors (NTF) - 404
	CodeNotFoundGeneric  = "HYPERFLEET-NTF-001"
	CodeNotFoundCluster  = "HYPERFLEET-NTF-002"
	CodeNotFoundNodePool = "HYPERFLEET-NTF-003"

	// Conflict errors (CNF) - 409
	CodeConflictExists  = "HYPERFLEET-CNF-001"
	CodeConflictVersion = "HYPERFLEET-CNF-002"

	// Rate Limit errors (LMT) - 429
	CodeRateLimitExceeded = "HYPERFLEET-LMT-001"

	// Internal errors (INT) - 500
	CodeInternalGeneral  = "HYPERFLEET-INT-001"
	CodeInternalDatabase = "HYPERFLEET-INT-002"

	// Service errors (SVC) - 502/503/504
	CodeServiceUnavailable = "HYPERFLEET-SVC-001"
	CodeServiceTimeout     = "HYPERFLEET-SVC-002"

	// Bad Request errors
	CodeBadRequest      = "HYPERFLEET-VAL-005"
	CodeMalformedBody   = "HYPERFLEET-VAL-006"
	CodeSearchParseFail = "HYPERFLEET-VAL-007"
	CodeNotImplemented  = "HYPERFLEET-INT-003"
)

Error codes in HYPERFLEET-CAT-NUM format

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceError

type ServiceError struct {
	RFC9457Code string
	Type        string
	Title       string
	Reason      string
	Details     []ValidationDetail
	HTTPCode    int
}

ServiceError represents an API error with RFC 9457 Problem Details support

func BadRequest

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

func Conflict

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

func DatabaseAdvisoryLock

func DatabaseAdvisoryLock(err error) *ServiceError

func FailedToParseSearch

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

func Find

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

Find looks up an error definition by its RFC 9457 code

func Forbidden

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

func GeneralError

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

func InvalidToken

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

func MalformedRequest

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

func New

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

New creates a new ServiceError with optional custom reason

func NotFound

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

func NotImplemented

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

func ServiceUnavailable added in v0.2.1

func ServiceUnavailable(reason string, values ...interface{}) *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 ValidationWithDetails

func ValidationWithDetails(reason string, details []ValidationDetail) *ServiceError

ValidationWithDetails creates a validation error with field-level details

func (*ServiceError) AsError

func (e *ServiceError) AsError() error

func (*ServiceError) AsProblemDetails

func (e *ServiceError) AsProblemDetails(instance string, traceID string) openapi.Error

AsProblemDetails converts the ServiceError to RFC 9457 Problem Details format

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

type ServiceErrors

type ServiceErrors []ServiceError

func Errors

func Errors() ServiceErrors

Errors returns all defined errors

type ValidationDetail

type ValidationDetail struct {
	Field      string      `json:"field"`
	Value      interface{} `json:"value,omitempty"`
	Constraint string      `json:"constraint,omitempty"`
	Message    string      `json:"message"`
}

ValidationDetail represents a single field validation error (RFC 9457 format)

Jump to

Keyboard shortcuts

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