Documentation
¶
Overview ¶
Package errors provides sentinel errors and structured error types for OPM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrValidation indicates a CUE schema validation failure. ErrValidation = errors.New("validation error") // ErrConnectivity indicates a network connectivity issue. ErrConnectivity = errors.New("connectivity error") // ErrPermission indicates insufficient permissions. ErrPermission = errors.New("permission denied") // ErrNotFound indicates a resource, module, or file was not found. ErrNotFound = errors.New("not found") )
Sentinel errors for known conditions.
Functions ¶
func NewValidationError ¶
NewValidationError creates a validation error with details.
Types ¶
type ConfigError ¶
type ConfigError struct {
// Context identifies which gate produced the error (e.g. "module").
Context string
// Name is the release name for display (e.g. "my-game-stack", "server").
Name string
// RawError is the original CUE unification or concreteness error.
RawError error
}
ConfigError is a structured validation error produced by the Module Gate when supplied values do not satisfy a #config schema.
It carries the raw CUE error tree so callers can obtain a human-readable summary via Error() or grouped diagnostics via GroupedErrors().
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error implements the error interface. Produces a human-readable summary: one line per unique CUE error position.
func (*ConfigError) GroupedErrors ¶
func (e *ConfigError) GroupedErrors() []GroupedError
GroupedErrors walks the raw CUE error tree and returns errors grouped by message. Each GroupedError holds the message and all distinct source positions (primary + contributing) that report it, so conflicts between multiple files appear as a single entry with multiple locations.
Returns nil if RawError is nil or produces no parseable errors.
func (*ConfigError) Unwrap ¶
func (e *ConfigError) Unwrap() error
Unwrap returns the underlying CUE error for errors.Is/As compatibility.
type DetailError ¶
type DetailError struct {
// Type is the error category (required).
Type string
// Message is the specific description (required).
Message string
// Location is the file path and line number (optional).
Location string
// Field is the field name for schema errors (optional).
Field string
// Context contains additional key-value context (optional).
Context map[string]string
// Hint provides actionable guidance (optional).
Hint string
// Cause is the underlying error (optional).
Cause error
}
DetailError captures structured error information.
func (*DetailError) Error ¶
func (e *DetailError) Error() string
Error implements the error interface.
func (*DetailError) Unwrap ¶
func (e *DetailError) Unwrap() error
Unwrap returns the underlying error.
type ErrorLocation ¶
type ErrorLocation struct {
// File is the values file name (basename only).
File string
// Line is the 1-based line number. Zero means no position information.
Line int
// Column is the 1-based column number.
Column int
// Path is the dot-joined CUE field path at this position (e.g. "values.db.port").
// May be empty when the error has no associated path.
Path string
}
ErrorLocation is a source position paired with its CUE field path. Used in GroupedError to record every location where an error message appears.
type FieldError ¶
type FieldError struct {
// File is the values file name where the error occurred.
File string
// Line is the 1-based line number in File.
Line int
// Column is the 1-based column number in File.
Column int
// Path is the dot-joined field path from the values root (e.g. "values.db.port").
Path string
// Message is the human-readable error description.
Message string
}
FieldError is a single validation error tied to a specific source location in a values file.
type GroupedError ¶
type GroupedError struct {
// Message is the human-readable error description shared by all locations.
Message string
// Locations holds one entry per distinct source position reporting this error.
Locations []ErrorLocation
}
GroupedError collects all source locations where the same error message appears. CUE can report the same logical error at multiple positions (e.g. both sides of a value conflict), so grouping by message collapses duplicates and makes conflicts immediately readable without a separate section.
func GroupedErrorsFromError ¶
func GroupedErrorsFromError(err error) []GroupedError
GroupedErrorsFromError attempts to extract CUE errors from any error (including wrapped ones such as fmt.Errorf("...: %w", cueErr)) and group them by message. This handles cases where CUE errors are wrapped before reaching the display layer.
Returns nil if no CUE error information can be extracted.
type TransformError ¶
TransformError indicates transformer execution failed.
func (*TransformError) Component ¶
func (e *TransformError) Component() string
Component returns the component name where the error occurred.
func (*TransformError) Error ¶
func (e *TransformError) Error() string
func (*TransformError) Unwrap ¶
func (e *TransformError) Unwrap() error
type ValidationError ¶
type ValidationError struct {
// Message describes what validation failed.
Message string
// Cause is the underlying error.
Cause error
// Details contains the formatted CUE error output.
Details string
}
ValidationError indicates the release failed validation.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error