Documentation
¶
Overview ¶
Package compositeerrors defines the typed, embedded error abstraction used across the Nuon platform.
A CompositeError is a regular Go error (it satisfies the standard error interface) plus typed metadata — a discriminator, a severity, and an optional list of structured Sections — that lets the dashboard present a rich, opinionated view without losing the ability to be returned through the call stack like any other error.
Composite errors are persisted by attaching a CompositeErrorData JSONB column to owner rows (component builds, sandbox runs, deploys, action runs, ..)
New typed errors are added by writing a struct that implements CompositeError in its own subpackage (e.g. compositeerrors/terraform/, compositeerrors/validation/).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompositeError ¶
type CompositeError interface {
error // headline — the one-line message users see
Type() Type
Severity() Severity
// Sections returns optional structured detail (what / why / fix).
// Returning nil is fine — the headline alone is a valid view.
Sections() []Section
}
CompositeError is a typed, structured error. Implementations satisfy the standard error interface (Error() returns the headline message), plus metadata used to persist and present the error in the dashboard.
type CompositeErrorData ¶
type CompositeErrorData struct {
Type Type `json:"type"`
Severity Severity `json:"severity"`
Message string `json:"message"`
Sections []Section `json:"sections,omitempty"`
Data json.RawMessage `json:"data"`
}
CompositeErrorData is the JSONB GORM column attached to owner rows. It captures a typed CompositeError's payload along with its headline message and structured sections, all frozen at write time.
To use, add this to a GORM model struct:
CompositeError *compositeerrors.CompositeErrorData `json:"composite_error,omitempty" gorm:"type:jsonb"`
func New ¶
func New(e CompositeError) *CompositeErrorData
New constructs a CompositeErrorData from a typed CompositeError. The implementation's data, headline message, and sections are captured at this point, all are frozen on the resulting record.
func (CompositeErrorData) GormDataType ¶
func (CompositeErrorData) GormDataType() string
GormDataType tells GORM to use a jsonb column.
func (*CompositeErrorData) Scan ¶
func (c *CompositeErrorData) Scan(value any) error
Scan implements database/sql.Scanner.