Errors
The errors package provides structured error types and thin wrapping helpers used
across launcher. Application code is meant to use these helpers instead of calling fmt.Errorf
directly, so that error wrapping is consistent and machine-inspectable.
Structured error types
ValidationError is returned when a semantic constraint is violated. It serves three
shapes:
- Enum errors (unknown value): populate
Value+ValidValuesviaNewValidationError(field, value, component, validValues). - Custom-message errors (missing field, bad format): populate
Message. - Wrapping errors:
Causeholds the error being reported andUnwrapreturns it, soerrors.Isanderrors.Assee through theValidationError. An unresolved type reference, for example, matchesoam.ErrTypeReferenceUnknown.
ParseError is returned when a document fails YAML parsing; it carries Kind,
File, Line, Column, and the wrapped cause (NewParseError(...)), and supports
errors.Unwrap.
PatchError is returned when a patch operation (pkg/patch) fails to apply. It carries
Operation, Path, ResourceName, Reason, and the wrapped Cause
(NewPatchError(operation, path, resourceName, reason, cause)), and supports errors.Unwrap.
Wrapping helpers
Wrap/Wrapf return nil when the input error is nil, so they are safe to use
unconditionally.
API overview
| Symbol | Purpose |
|---|---|
ValidationError, NewValidationError | Semantic constraint violations (enum, custom, or wrapping a cause). |
ParseError, NewParseError | YAML parse failures with location. |
PatchError, NewPatchError | Patch operations (pkg/patch) that fail to apply. |
New, Errorf | Create plain/formatted errors. |
Wrap, Wrapf | Wrap an error with context (nil-safe). |
Is, As | errors.Is/errors.As passthroughs for inspection. |
The package comment in doc.go gives the same summary on pkg.go.dev.